|
-
Feb 9th, 2003, 10:11 AM
#1
Thread Starter
Member
Template problem
class CAnyBaseClass
{
public:
CAnyBaseClass();
~CAnyBaseClass();
};
// Definitions ...
template<class BASE>
class CMyClass : public BASE
{
public:
CMyClass();
~CMyClass();
};
// Definitions etc...
...
CMyClass<CAnyBaseClass>* pMyClass = new CMyClass<CAnyBaseClass>;
causes LNK2019 linker error.
I don`t know what to do!
Please, help !
-
Feb 9th, 2003, 10:45 AM
#2
transcendental analytic
prolly your defintions there which you haven't posted
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 9th, 2003, 12:01 PM
#3
Thread Starter
Member
With definitions I mean definitions of constructor and destructor
CAnyBaseClass::CAnyBaseClass()
{
}
CAnyBaseClass::~CAnyBaseClass()
{
}
and
CMyClass::CMyClass()
{
}
CMyClass::~CMyClass()
{
}
I have just written them only to avoid compiler error, so I haven`t written any specific code inside them.
I tried to put the defintions in the header file of the class, and that avoided the error. But when they were in the .cpp file, linker gives error.
-
Feb 9th, 2003, 12:22 PM
#4
transcendental analytic
don't forget that CAnyBaseClass is a template class, the function definitions are thus templates as well
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 9th, 2003, 12:22 PM
#5
Frenzied Member
ALL template code goes in headers, always. Since the template code is only compiled when it is used in your program, if you put it in a source file, it wont be found when the compiler tries to compile it. It will compile, since the prototype exists, but the implementation is not there.
Z.
-
Feb 9th, 2003, 12:40 PM
#6
Thread Starter
Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|