/////////////////////////////////////////////////////////////// // // // syntax1.cpp - demonstrate basic syntax for declarations, // // definitions, and invocations // // // /////////////////////////////////////////////////////////////// #include // declarations class X { // declarations // " public: // " X(); // " X(const X &x); // " void put(int i); // " int get( ); // " // " private: // " int data; // " }; // " X::X() { cout << "void ctor" << endl; } // definitions // " X::X(const X &x) { // " cout << "copy ctor" << endl; // " } // " // " void X::put(int i) { data = i; } // " // " int X::get( ) { return data; } // " void main() { X x; // declaration x.put(2); // invocation cout << "value of data member = " // " << x.get() // " << endl; // " }