/////////////////////////////////////////////////////////////// // stringBase.cpp - Visual Studio help session demo #include "stringBase.h" stringBase::stringBase(const std::string& tag) { *this += '<'; *this += tag + ">'; } stringBase::~stringBase() { std::cout << " being destroyed\n"; } void stringBase::body(const std::string& text) { size_t pos = this->find(">"); if(pos < this->length()) this->insert(pos+1,text); } #ifdef TEST_STRINGBASE void main(int argc, char* argv[]) { const std::string title = "Testing stringBase class"; std::cout << "\n " << title; std::cout << "\n " << std::string(title.length()+2,'=') << "\n"; stringBase elem1("aTag"); elem1.body("this is a body"); std::cout << "\n " << elem1 << "\n"; stringBase elem2("bTag"); elem2.body("another body"); std::cout << "\n " << elem2 << std::endl; stringBase* pDoc = new stringBase("anXMLdocument"); pDoc->body(elem1 + elem2); std::cout << "\n " << *pDoc << "\n\n"; delete pDoc; } #endif