C++ Codes
Algorithms
Algorithm Analysis in C++
Beginners
Code Snippets
Graphics
Data Structures
File Manipulation
Games
Mathematics
Miscellaneous
Visual C++ Library
C++ > Data Structures and Algorithm Analysis in C++ sample source codes
TestMemoryCell.cpp - MemoryCell test program (Fig 1.22)
TestMemoryCell.cpp - MemoryCell test program (Fig 1.22) #include <iostream.h> #include "MemoryCell.h" #include "mystring.h" // OOPS: I forgot to put a + operator in the string class. // So it's here: string operator+( const string & lhs, const string & rhs ) { string result = lhs; return result += rhs; } int main( ) { MemoryCell<int> m1; MemoryCell<string> m2( "hello" ); m1.write( 37 ); m2.write( m2.read( ) + " world" ); cout << m1.read( ) << endl << m2.read( ) << endl; return 0; }
Privacy Policy
|
Link to Us
|
Links