I'm trying to compile a program I made, however, I keep getting an error form MSVC++ that one of my classes has no constructors. (Not that there is no appropriate constructor, it's telling me I don't even have one).
Here's the definition for the class (it's part of a linked list):
The only place the InvTail constructor is called from is the InvHead constructor. (The head creates the tail, you know the drill). All the constructor does is try and create a new InvTail on the heap and pass it's this pointer as the argument.Code:class InvTail : public InvItem { public: InvTail(InvItem *); virtual ~InvTail() {} ... private: }; // prev and next are inherited from InvItem InvTail::InvTail(InvItem *head) { prev = head; next = 0; }
If I change "next = new InvTail(this);" to "next = new InvTail();" it tells me it can't find an appropriate constructor, (as I would expect), but as it is it gives simply tells me that there isn't a constructor, and the compile fails. Any help would be appreciated.Code:InvHead::InvHead() { next = new InvTail(this); }



LinkBack URL
About LinkBacks


