Stealth1024
Platinum Member
Alright I've programmed in java for a while and I'm working on a project in C++.
C++ doesn't have interfaces as far as I can tell, but I think I can do about the same thing by creating a purely virtual .h header file with a class description and then create subclass .h/.cpp pairs from this?
My questions have to do with the constructors. Should they be declared virtual? I will not have a constructor of the same name in my implementing classes.
I did read that the destructor should be virtual so it knows to execute the subclass's deconstructor.
I have looked at several guides online but no one gives examples with seperate .h and .cpp files and thus I'm not sure where I need which included, etc.
Basically I'm creating a puzzle interface, with several puzzles that implement it. And there's a solver class that is expecting any given puzzle but it doesn't know which one. Since all puzzles have the same methods, it can use generic algorythms to solve any puzzle that conforms to this interface.
I even got all the hard work done with pointers, the STL, solver class written and tested, etc....
- confused C++ programmer
C++ doesn't have interfaces as far as I can tell, but I think I can do about the same thing by creating a purely virtual .h header file with a class description and then create subclass .h/.cpp pairs from this?
My questions have to do with the constructors. Should they be declared virtual? I will not have a constructor of the same name in my implementing classes.
I did read that the destructor should be virtual so it knows to execute the subclass's deconstructor.
I have looked at several guides online but no one gives examples with seperate .h and .cpp files and thus I'm not sure where I need which included, etc.
Basically I'm creating a puzzle interface, with several puzzles that implement it. And there's a solver class that is expecting any given puzzle but it doesn't know which one. Since all puzzles have the same methods, it can use generic algorythms to solve any puzzle that conforms to this interface.
I even got all the hard work done with pointers, the STL, solver class written and tested, etc....
- confused C++ programmer