On the following code I get an error for the TEST constructor, saying:
"cannot construct base class 'ELEMENT'"
WHY!?????
my.h file (part):
-----------------------------------------------------------
class ELEMENT
{
public:
string element_name;
string element_data;
vector<ELEMENT*> elements;
void get_element();
//constructor
ELEMENT(string _element_name, int teller);
//destructor
~ELEMENT();
};
class TEST : public ELEMENT
{
public:
// Constructor
TEST();
};
-----------------------------------------------------------
my.c file:
-----------------------------------------------------------
ELEMENT::ELEMENT( string _element_name , int teller )
{
if ( teller < 10 )
{
teller++;
element_name = _element_name;
if ( teller == 2 )
{
elements.push_back( new TEST() );
}
elements.push_back( new ELEMENT( _element_name , teller ) );
}
}
ELEMENT::~ELEMENT()
{
for ( int i = 0 ; i < elements.size() ; i++ )
{
cout << elements->element_name << "deleted";
delete elements;
}
}
void
ELEMENT::get_element()
{
for ( int i = 0 ; i < elements.size() ; i++ )
{
cout << elements->element_name;
elements->get_element();
}
}
TEST::TEST()
{
element_name = "test";
}
-----------------------------------------------------------
"cannot construct base class 'ELEMENT'"
WHY!?????
my.h file (part):
-----------------------------------------------------------
class ELEMENT
{
public:
string element_name;
string element_data;
vector<ELEMENT*> elements;
void get_element();
//constructor
ELEMENT(string _element_name, int teller);
//destructor
~ELEMENT();
};
class TEST : public ELEMENT
{
public:
// Constructor
TEST();
};
-----------------------------------------------------------
my.c file:
-----------------------------------------------------------
ELEMENT::ELEMENT( string _element_name , int teller )
{
if ( teller < 10 )
{
teller++;
element_name = _element_name;
if ( teller == 2 )
{
elements.push_back( new TEST() );
}
elements.push_back( new ELEMENT( _element_name , teller ) );
}
}
ELEMENT::~ELEMENT()
{
for ( int i = 0 ; i < elements.size() ; i++ )
{
cout << elements->element_name << "deleted";
delete elements;
}
}
void
ELEMENT::get_element()
{
for ( int i = 0 ; i < elements.size() ; i++ )
{
cout << elements->element_name;
elements->get_element();
}
}
TEST::TEST()
{
element_name = "test";
}
-----------------------------------------------------------