#include <iostream> #include <string> #include <map> using namespace std; class Content { public: static Content* getContent(const string& type); static void printCurrentTypes(); private: static map<string,content*> types; string type; Content(const string& t) : type( t ) {} }; map<string,content*> Content::types; void Content::printCurrentTypes() { if (!types.empty()) { cout << "Number of instances made = " << types.size() << endl; for (map<string,content*>::iterator iter = types.begin(); iter != types.end(); ++iter) { cout << (*iter).first << endl; } cout << endl; } } int main(void) { Content::getContent("text/plain"); Content::printCurrentTypes(); Content::getContent("image/gif"); Content::printCurrentTypes(); Content::getContent("image/jpg"); Content::printCurrentTypes(); return 0; }
Content::printCurrentTypes
Content::getContent
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)