Hi. I don't know if my subject really made sense, so I'll try to explain here. I have a file that contains all my classes, and in those classes are some derived classes with virtual functions in them. Is it possible to put all the code in those virtual functions into a separate file? Such as:
Code:
virtual void displayInfo() {
cout << title << endl;
cout << author << endl;
cout << description << endl;
cout << sku << endl;
cout << cost << endl;
cout << quantity << endl;
}
This function is in the actual derived class right now.
Can I clean it up a bit and make it look like this somehow?
Code:
virtual void displayInfo() { }
And in a separate .cpp file:
Code:
virtual void dClass::vfunction() {
cout << title << endl;
cout << author << endl;
cout << description << endl;
cout << sku << endl;
cout << cost << endl;
cout << quantity << endl;
}
dClass was my derived class by the way.
Can I take that code out of the class, and put it in a separate .cpp file? I hope this makes sense. The code above didn't work when I tried it that way, but I'm hoping there's someway to do this.
Thanks.