A Collection of Design Pattern Interview Questions Solved in C++ by Antonio Gulli

A Collection of Design Pattern Interview Questions Solved in C++ by Antonio Gulli

Author:Antonio Gulli [Gulli, Antonio]
Language: eng
Format: epub
Published: 2014-05-22T00:00:00+00:00


private:

unsigned int shared_name_;

};

class FlyweightFactory{

public:

static Icon * getIcon(unsigned int name)

{

std::vector<Icon *>::const_iterator it, it_end;

it = icons_.begin();

it_end = icons_.end();

for (; it != it_end; ++it){

if ((*it)->getName() == name){

std::cout <<

"\tFlyweight -> reusing an icon with name="

<< name << std::endl;

return *it;

}

}

icons_.push_back(new Icon(name));

std::cout <<

"\tCreated a new icon with name="

<< name << std::endl;

return icons_.back();

}; // an example: get an Icon allocated



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.