| | |
Error C2440 and C2504
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2008
Posts: 41
Reputation:
Solved Threads: 0
Hi to all
I have a project, and I found 2 the errors in derived class,
says the first:
'BaseClass' : base class undefined
the number of error is :Error C2504:
and I include the file:
#include "BaseClass.h"
and make declare base class with extern.
but still the error.
.........................
says the second:
'cannot convert from 'DerivedClass **' to 'BaseClass **'.
if I make pointer from base point to derived
// declaration
BaseClass ** PointerBaseClass;
//initialization
PointerBaseClass = new DerivedClass * [size];
// this is code make in another class
the number of error is :error C2440:
Have you got any idea ?
the msdn help is not really clear,
I have made a lot of tries but no issue ....
Thank's for your time ...
I have a project, and I found 2 the errors in derived class,
says the first:
'BaseClass' : base class undefined
the number of error is :Error C2504:
and I include the file:
#include "BaseClass.h"
and make declare base class with extern.
but still the error.
.........................
says the second:
'cannot convert from 'DerivedClass **' to 'BaseClass **'.
if I make pointer from base point to derived
// declaration
BaseClass ** PointerBaseClass;
//initialization
PointerBaseClass = new DerivedClass * [size];
// this is code make in another class
the number of error is :error C2440:
Have you got any idea ?
the msdn help is not really clear,
I have made a lot of tries but no issue ....
Thank's for your time ...
Last edited by mini programmer; Jan 6th, 2009 at 12:13 pm.
•
•
Join Date: Dec 2008
Posts: 41
Reputation:
Solved Threads: 0
OK..
My project has more than 10 files,
-so I attempt to put which is important.-
My project has many of tasks;
and the all it before now is correct.
I have 4 classes,
2 is derived from BaseClass , and the fourth (class4) contain :
and if I use the PointerBaseClass as array, appear the same error
=================================
the second error (( Error C2504: 'BaseClass' : base class undefined )), appear in DerivedClass1 and DerivedClass2
Thanks a lot to you for help me...
My project has more than 10 files,
-so I attempt to put which is important.-
My project has many of tasks;
and the all it before now is correct.
I have 4 classes,
2 is derived from BaseClass , and the fourth (class4) contain :
C++ Syntax (Toggle Plain Text)
private : BaseClass ** PointerBaseClass ; public: class4 () { PointerBaseClass = new DerivedClass1* [size]; /* here appear the error C2440: '=' : cannot convert from 'DerivedClass1*' to 'BaseClass *' */ }
and if I use the PointerBaseClass as array, appear the same error
C++ Syntax (Toggle Plain Text)
bool class4:: enrollStudent (BaseClass & s) { DerivedClass1* PointerDerivedClass1 ; PointerDerivedClass1 = dynamic_cast <DerivedClass1*> (& s); // because I use some functions in DerivedClass1 not in BaseClass if ( PointerDerivedClass1 ) { for (int i = 0 ; i < saze; i++) { if ( PointerBaseClass [i] == NULL) { PointerBaseClass [i] = ; // here the error } } }
=================================
the second error (( Error C2504: 'BaseClass' : base class undefined )), appear in DerivedClass1 and DerivedClass2
C++ Syntax (Toggle Plain Text)
class DerivedClass1 :public BaseClass { // here the error private : ......... public:.......
Thanks a lot to you for help me...
Last edited by mini programmer; Jan 6th, 2009 at 2:16 pm.
>>BaseClass ** PointerBaseClass ;
Why does that have two stars? If you want an array of classes all you need is one star. Two stars indicates either an array of pointers to array of classes, or a pointer to a pointer. The code snippet you posted doesn't seem to need either of those.
Why does that have two stars? If you want an array of classes all you need is one star. Two stars indicates either an array of pointers to array of classes, or a pointer to a pointer. The code snippet you posted doesn't seem to need either of those.
BaseClass* PointerBaseClass = new DerivedClass[size]; Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Other Threads in the C++ Forum
- Previous Thread: Testing whether function is interruptable or not
- Next Thread: Trouble sepperating to if statements.
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






