/* Sample of a very simple C++ class */ #include // included for cout, cin, etc. using namespace std; // begin class definition and implementation class world { public: world() { cout << "Hello World" << endl; } // ctor ~world() { cout << "Goodbye" << endl; } // dtor void DoIt() { cout << "DoIt called\n"; } private: // this part is not accessible from outside of world }; // semicolon!! world hello; // declare an instance (called // "hello") of the "world" class // begin main program int main() { cout << "This is main." << endl; hello.DoIt(); } // Program output: // Hello World // This is main. // DoIt called // Goodbye