Solved regarding inheritance.
-
Hello everyone, I can not inherit one class of cpp file into another class of cpp file. i get error like undefined base class etc.
-
Do you have separate *.h and *.cpp file ? Did you include the base class header file ? Are you including A class in B and B class in A ? Just check
-
Yes i have separate .cpp and .h file and also include header file of one cpp file into another header file of cpp file. Still i get error "Base class undefined".
-
Hi,
The please show your code. It's impossible to tell what is going wrong without any code.
-
Code is.. Base class is Point3d and child class is Vector3d.
#ifndef VECTOR3D_H
#define VECTOR3D_H#include <QVector3D>
#include <QColor>
#include <QListWidget>
#include <QList>
#include "point3d.h"class Vector3d:public Point3d
{
public:
Vector3d();
Vector3d(float xp, float yp, float zp);
void Dispose();
Vector3d clone();
....Error is:C2504: 'Point3d' : base class undefined
-
I'm facing the same error like :
error: C2504: 'Point3d' : base class undefined -
@NgtLvr
hi
and if you look in
point3d.hwhat is the class name there ?
-
@mrjj
#include "vector3d.h"
class Point3d
{};
-
@NgtLvr You have cyclic dependencies between your header files: vector3d.h includes point3d.h and point3d.h includes vector3d.h. First question is: why does your Point3d need to know anything about Vector3d?
-
oops!!! Sorry, You are right, there is a cyclic dependencies between two classes...
Thanks for your quick response...
-
Cool. A->B and B->A Cyclic case. This is what I said my first response. Enjoy. Move the issue to "Solved" state.
-
Yeah that's the problem as you say cause of there are huge numbers of cpp file in hierarchy so that's the matter.
thank you,
@jsulm
@dheerendra