// OopHello.C // (c) Burt Rosenberg 1996 // This program demonstrates a basic approach of Object // Oriented Programming. // Also introduces strings as array of char. #include #include class Greetings { private: char * message ; public: Greetings( char m[] ) ; void print(void) ; void set(char m[]) ; } ; Greetings::Greetings( char m[] ) { message = new char[strlen(m)+1] ; strcpy( message, m ) ; } void Greetings::print ( void ) { cout << message << endl ; } void Greetings::set( char m[] ) { delete message ; message = new char[strlen(m)+1] ; strcpy( message, m ) ; } void main() { Greetings hello( "Hello World" ) ; hello.print() ; hello.set( "Goodbye World" ) ; hello.print() ; }