template<class T> error
<p>I have a: header.cpp, header.hpp and a test_header.cpp. </p>

<p>In header.hpp i've i have:</p>

<pre><code>class MyClass
  {
    public;
    MyClass();
    std::string name;
    //...code with other variables,methods;

 class MySecondClass
  {

    public:
    MySecondClass();

    std::string surname;
    //..code with other variables,methods

  }*MySC;

   public:
   template&lt;class T&gt;
   bool method(T&amp; obj);

    {



    if (typeid(MyClass)=typeid(obj))
     {
       MyClass *s= new MyClass();
        *s=obj //i want to save everything that i have in obj into s;
        //call  method "MyMethod" and work with s

    }
     else if (typeid(MyClass::MySecondClass)=typeid(obj))
      {
        MyClass::MySecondClass *s1= new MyClass::MySecondClass();
        *s1 = obj;
        //call "MyMethod" and work with s1;
      }
     return true;
  }

}*mycls;
</code></pre>

<p>In test_header.cpp I have</p>

<pre><code>{
  MyClass *mycls = new MyClass();
  MyClass::MySecondClass *mysec_cls= new MyClass::MySecondClass();

   if (mycls-&gt;method&lt;MyClass&gt;(*mycls) 
              {//code
               }
   if (mycls-&gt;method&lt;MyClass::MySecondClass&gt;(*mysec_cls)
           {//code
           }
}
</code></pre>

<p>I have an error saying that mysec_cls is not of type MyClass. As i've realised the pointer goes to the first if and never on else. </p>

<pre><code>.h error: no match for operator= in *s1 = obj. 
note: candidates are: MyClass&amp; MyClass::operator=(const MyClass&amp;)
</code></pre>

<p>I don't have this error if in test_header.cpp i have just one if and if in template i only have the reference from the if in test_header, but if ihave more than one refference to T&amp; obj i have the error i've mentioned.</p>

<p>Why? how to change this? i am compiling using g++.</p>
