template<class T>
class CreateNewObject
{
public:
T cmd;
};
class Object
{
code...
}
class Ship : public Object
{
code...
}
In main I now have this code CreateNewObject tship; but now I get a link error when trying to use code from the object class.
What am I doing wrong?
help with templates and inheritance
I got a couple of classes like this:
You need to pass in the template parameter while declaring or instantiating the class object.
E.g.
With passing the template parameter, the compiler is not going to generate the code for the CreateNewObject class. Hence, you get the linker error while trying the use the class / object
E.g.
CreateNewObject<Ship> newobject;
With passing the template parameter, the compiler is not going to generate the code for the CreateNewObject class. Hence, you get the linker error while trying the use the class / object
I meant to mean
"Without passing the template parameter, the compiler is not going to generate the code for the template class"
"Without passing the template parameter, the compiler is not going to generate the code for the template class"
I think he knows that. If he is doing templates, I am sure he knows how they work.
The point I was trying to make, is Microsoft vc++6 has a very well known bug LInker error c1001.
There are ways to fix that, so that is why I asked.
The point I was trying to make, is Microsoft vc++6 has a very well known bug LInker error c1001.
There are ways to fix that, so that is why I asked.
no thats not it, my fault that was not the error it gave me.
Il post them
main.obj : error LNK2001: unresolved external symbol "public: void __thiscall Object::DrawToScreen(void)" (?DrawToScreen@ Object@@QAEXXZ)
Debug/pong.exe : fatal error LNK1120: 1 unresolved externals
sorry again for wasting your time.
Il post them
main.obj : error LNK2001: unresolved external symbol "public: void __thiscall Object::DrawToScreen(void)" (?DrawToScreen@ Object@@QAEXXZ)
Debug/pong.exe : fatal error LNK1120: 1 unresolved externals
sorry again for wasting your time.
That means you declared a function prototype DrawToScene(); in class Object, but never declared the function body.
Simply put (in your Object cpp file)
Simply put (in your Object cpp file)
void Object::DrawToScene(){}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement