Ah right! Im on my first steps on c++, What Im trying to do is
have this "basic node" class wich just take an id and from there
usign inheritance make "linked list node" and "binary tree node" classes my code so far looks like this
void main()
{
sLink* pChainLink; //sLink stays for single list link
sLink ChainLinkNo1 (pChainLink, 1);
sLink ChainLinkNo2 (ChainLinkNo1, 2);
sLink ChainLinkNo3 (ChainLinkNo2, 3);
sLink * tmp = ChainLinkNo3;
while(tmp != 0){
cout << tmp->Id();
tmp = ChainLinkNo3.Next();
}
}
and the other 2 headers
//sLink.h
class sLink : public Link
{
public:
sLink (sLink* pNext, int id): Link(id), _pNext (pNext) {}
sLink * Next () const { return _pNext; }
private:
sLink * _pNext;
};
link.h //the basic node
class Link
{
public:
Link (int id): _id (id) {}
int Id () const { return _id; }
private:
int _id;
};
the compiler error says:
(red code position ) 'initializing' : cannot convert from 'Link *' to 'sLink *'
Some reason why's ... thanks