/ ************************************************************************ * * Purpose: * Author: M J Leslie * Date: 26-Oct-98 * ************************************************************************/ #include <stdlib.h> #include <iostream.h> // Instead of stdio.h class string { public: // Constructor. string() { Age=35; } // Destructors (Clear storage - free()). ~String() {} // ... Overloaded functions. void print() { cout << "Martin is " << Age << endl ; } void print(char * str) { cout << "** " << str << " **\n"; } private: int Age; // Declare Age }; main() { string test; // Constructor inserted by the compiler here. test.print(); test.print("Leslie"); }
file: /Techref/language/ccpp/cppref/examples/class2.cc, 0KB, , updated: 1998/10/27 13:33, local time: 2024/11/27 03:52,
3.145.105.149:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://techref.massmind.org/techref/language/ccpp/cppref/examples/class2.cc"> language ccpp cppref examples class2</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to techref.massmind.org! |
.