pbl when changing files from .inl to .cpp

  • Thread starter Christel Chamaret
  • Start date
C

Christel Chamaret

Hi people,

I am a beginner for using templates in C++. I think the system is nice
but why using it when it is not necessary. Anyway, in my code I need to
remove the "template aspect" of a file for compatibility with other
parts of the code. That means, I had a file like that :


(in a file MyClass.inl)
template <class T>
MyClass<T>::MyMethod(...,...,...)
{
....
}

(in a file MyClass.hpp)
template <class T>
class MyClass
{
public:
MyClass2 MyObject2;
}


(not templated class in a file MyClass2.hpp)
class MyClass2
{
....
}


I wanted to change that by removing the templates in MyClass, so now I got:

(in a file MyClass.cpp)
MyClass::MyMethod(...,...,...)
{
....
}

(still the same, in a file MyClass.hpp)
class MyClass
{
public:
MyClass2 MyObject2;
}


(still the same, not templated class in a file MyClass2.hpp)
class MyClass2
{
....
}

My problem is that the second class (MyClass2) is not recognized anymore
by the new file MyClass.hpp and I got the following message:
error C2079: 'MyObject2' uses undefined class 'MyClass2'

Someone has an idea, please ?
 
V

Victor Bazarov

Christel said:
[..]

My problem is that the second class (MyClass2) is not recognized
anymore by the new file MyClass.hpp and I got the following message:
error C2079: 'MyObject2' uses undefined class 'MyClass2'

Someone has an idea, please ?

Include 'MyClass2.hpp' in the 'MyClass.hpp'.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top