|
-
October 20th, 2010, 06:15 AM
#1
Virtual and inheritance, can't find the problem
Hi, I get an "undefined reference to `vtable for controlSystem'" when compiling the following code. I can't find the problem, I thought that this compiler message appeared when you forgot to implement a virtual member, but i think it's not my case.
Thanks in advance.
Code:
class controlSystem {
protected:
byte varNumber;
byte varSize;
public:
controlSystem();
byte iBL (unsigned int value);
byte iBH (unsigned int value);
unsigned int b2I(byte bH, byte bL);
virtual unsigned int calculateOutput (unsigned int fullStatus[17]);
virtual void sensorUpdate (unsigned int lastValue[16], unsigned int newValue[16]);
virtual void saveEEPROM(unsigned int position);
virtual void initializeEEPROM(unsigned int position);
virtual void loadEEPROM(unsigned int position);
};
/*fin de control System e inicio de thresholdSystem*/
class thresholdSystem : public controlSystem {
private:
unsigned int _threshold[16];
unsigned int _valueObj[16];
boolean _isrising[16];
unsigned int _active;
protected:
public:
thresholdSystem();
void saveEEPROM (unsigned int position);
void initializeEEPROM (unsigned int position);
void loadEEPROM (unsigned int position);
unsigned int calculateOutput (unsigned int [17]);
void sensorUpdate (unsigned int [16], unsigned int [16]);
};
---------------------------
byte controlSystem::iBL (unsigned int value) {
...
}
byte controlSystem::iBH (unsigned int value) {
...
}
unsigned int controlSystem::b2I(byte bH, byte bL) {
...
}
controlSystem::controlSystem () {
int a=0;
}
thresholdSystem::thresholdSystem () {
...
}
//Cambiar código para coger dirección por parámetro
void thresholdSystem::loadEEPROM (unsigned int position) {
...
}
void thresholdSystem::saveEEPROM (unsigned int position) {
...
}
void thresholdSystem::initializeEEPROM (unsigned int position) {
...
}
unsigned int thresholdSystem::calculateOutput (unsigned int fullStatus[17]) {
...
}
void thresholdSystem::sensorUpdate (unsigned int lastValue[16], unsigned int newValue[16]){
...
}
-
October 20th, 2010, 06:55 AM
#2
Re: Virtual and inheritance, can't find the problem
Where are the implementations for controlSystem?
If you don't want to provide implementations for controlSystem, make the virtual functions pure virtuals.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
-
October 20th, 2010, 06:57 AM
#3
Re: Virtual and inheritance, can't find the problem
It's in the code, isn't it?
Code:
controlSystem::controlSystem () {
int a=0;
}
-
October 20th, 2010, 07:01 AM
#4
Re: Virtual and inheritance, can't find the problem
Anyways, to make it pure virtual (the constructor) should I put
Code:
controlSystem::controlSystem() = 0 {}
or should I make the entire class virtual?
-
October 20th, 2010, 07:13 AM
#5
Re: Virtual and inheritance, can't find the problem
 Originally Posted by scarnia
It's in the code, isn't it?
Code:
controlSystem::controlSystem () {
int a=0;
}
 Originally Posted by scarnia
Anyways, to make it pure virtual (the constructor) should I put
Code:
controlSystem::controlSystem() = 0 {}
or should I make the entire class virtual?
That's a constructor. Constructors can't be virtual (nor classes...)
No, I'm talking about:
virtual unsigned int calculateOutput (unsigned int fullStatus[17]);
virtual void sensorUpdate (unsigned int lastValue[16], unsigned int newValue[16]);
virtual void saveEEPROM(unsigned int position);
virtual void initializeEEPROM(unsigned int position);
virtual void loadEEPROM(unsigned int position);
I don't see their definition (implementation) for controlSystem.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
-
October 20th, 2010, 03:12 PM
#6
Re: Virtual and inheritance, can't find the problem
Tags for this Thread
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
|