//------------------------------------------------------------- // cstr.h // // (from "C++ in Plain English" by Brian Overland) // // This file declares the CStr class. // Every module that refers to CStr must include this file. class CStr { char sData [256]; public: char *get (void); int getlength (void); void cpy (char *s); void cat (char *s); }; //------------------------------------------------------------- // cstr.cpp // // (from "C++ in Plain English" by Brian Overland) // // This file contains definitions of CStr functions. // Compile this file and link to the project. #include "cstr.h" #include char *CStr::get (void) // Return ptr to string data. { return sData; } int CStr::getlength (void) // Return length { return strlen (sData); } void CStr::cpy (char *s) // Copy from string arg { strcpy (sData, s); } void CStr::cat (char *s) // Concatenate string arg onto object { strcat (sData, s); } //------------------------------------------------------------- // main.cpp // #include #include "cstr.h" int main () { CStr string1, string2; string1.cpy ("My name is "); string2.cpy ("Bill."); string1.cat (string2.get()); puts (string1.get()); return 0; }