Inheritence problem
I think I might have a problem with inheritence...
I start with a base CVector class
then from that I inherit to from CPoint (there are some differences between them but most everything is the same).
class CPoint : public CVector
Now, My CSphere class''s constructor takes this:
CSphere(const CPoint &a_Centre, const float &a_Radius);
but when trying to create a sphere like this I get :
CNode::New(CSphere(CPoint(0,0,0),65536));
Test.cpp(18) : error C2661: ''CPoint::CPoint'' : no overloaded function takes 3 parameters
I''m assuming the CVector constructor can be used that does take 3 parameters like this:
CVector(float a_X, float a_Y, float a_Z);
Why is CPoint unable to use CVector constuctor?
Many thanks
Chris
Chris Brodie
You can only rely on the base class 'no-argument' constructor, all other constructors must be written explicitly in the derived class.
The CPoint '3 argument constructor' can be very simple, using the initializer list, like so:
CPoint::CPoint (float x, float y, float z) : CVector(x, y, z)
{// no need for any code in here}
Then the constructor for CVector will be called.
Cheers
Matt
Edited by - 3dmodelman on March 10, 2001 4:00:35 AM
The CPoint '3 argument constructor' can be very simple, using the initializer list, like so:
CPoint::CPoint (float x, float y, float z) : CVector(x, y, z)
{// no need for any code in here}
Then the constructor for CVector will be called.
Cheers
Matt
Edited by - 3dmodelman on March 10, 2001 4:00:35 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement