constructor is in implementation file or main program file?
The definition, or the invokation of the constructor?
I'd like to take a guess, constructor implementation is in the main program file. :p
Right; you have a header file, like myclass.h, with the class definition and all the constructors and destructors and method prototypes and definitions. // Myclass.h class Myclass { Myclass(); ~Myclass(); // More stuff }; Then you have a separate file implementing those constructors and destructors etc. // Myclass.cpp Myclass::Myclass() { // ctor } Myclass::~Myclass() { // dtor } // More stuff
You don't typically have either defined in the same file as the main function. Instead, you would include Myclass.h if you want to use Myclass objects. #include "Myclass.h" int main() { Myclass myobject; // etc. }
sorry I forgot to put `public:' before the constructors and destructors :-P
Join our real-time social learning platform and learn together with your friends!