title: How SC_CTOR works in SystemC
body: <p>In SystemC module constructor can be defined using <code>SC_CTOR</code> macro:</p>
  
  <pre><code>#define SC_MODULE(user_module_name)                   \
      struct user_module_name : ::sc_core::sc_module
  
  #define SC_CTOR(user_module_name)                     \
      typedef user_module_name SC_CURRENT_USER_MODULE;  \
      user_module_name( ::sc_core::sc_module_name )
  </code></pre>
  
  <p>Need to understand use scope specifier operator before <code>sc_core</code>.
  As per the macro user can generate constructor but it takes argument <code>sc_module_name</code>.</p>
  
  <p>User module <code>struct user module</code> is inheriting class <code>sc_module</code>, In class <code>sc_module</code> there are different overloaded constructor like</p>
  
  <pre><code>sc_module();
  sc_module( const sc_module_name&amp; nm ); /* for those used to old style */
  
  /* DEPRECATED */ sc_module( const char* nm );
  /* DEPRECATED */ sc_module( const std::string&amp; nm );
  </code></pre>
  
  <p>As per <code>SC_CTOR</code> it is declaring any object of type sc_moduke_name in constructor body if expanded the constructor will take form <code>user_module(::sc_core::sc_module) { /*constructor body*/}</code>.
  To understand simulate same code but failed to create object of type struct B </p>
  
  <pre><code>class mname {
      private:
              char *name;
      public:
              mname() {
                      cout &lt;&lt; "mname constructor invoked\n";
                      cout &lt;&lt; "\t name\t" &lt;&lt; name;
              }
  };
  
  class A {
      friend class mname;
      private:
      mname * mn;
      public:
      A() {
              cout &lt;&lt; "A constructor called\n";
      }
      A(const mname&amp; m) {
              cout &lt;&lt; "freind class constructor of A\n";
      }
      A(const std:: string&amp; s) {
              cout &lt;&lt; "string type construfctor\n";
      }
  };
  
  struct B: A {
      B(mname ) {
              cout     &lt;&lt; "struct b cosntructor called\n";
      }
  
  };
  
  int main() {
  
      B obj(mname);
      return 0;
  }
  </code></pre>