Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <vector>
- #include <iostream>
- using namespace std;
- class Entity
- {
- private:
- const string word;
- const bool boolean;
- const signed int integer;
- static signed int entityCount;
- public:
- Entity(void);
- Entity(const signed int& integer, const string& word, const bool& boolean);
- static signed int getEntityCount(void);
- const string* const getWord(void) const;
- const bool* const getBoolean(void) const;
- const signed int* const getInteger(void) const;
- virtual void print(void) = 0; // const;
- };
- class SpecificEntity : public Entity
- {
- public:
- SpecificEntity(void);
- SpecificEntity(const signed int& integer, const string& word, const bool& boolean);
- void print(void) const;
- };
- int Entity::entityCount = 0;
- Entity::Entity(void) : Entity(0, "", false) {}
- Entity::Entity(const signed int& integer, const string& word, const bool& boolean)
- : integer(integer)
- , word(word)
- , boolean(boolean)
- {
- this->print();
- ++Entity::entityCount;
- }
- const string* const Entity::getWord(void) const { return &this->word; }
- const bool* const Entity::getBoolean(void) const { return &this->boolean; }
- const signed int* const Entity::getInteger(void) const { return &this->integer; }
- signed int Entity::getEntityCount(void) { return Entity::entityCount; }
- /*
- void Entity::print(void) const
- {
- cout
- << "Integer: " << this->integer << endl
- << "Word: " << this->word << endl
- << "Boolean: " << this->boolean << endl
- << endl;
- }
- */
- void SpecificEntity::print(void) const
- {
- // this->print();
- cout << "Modified";
- }
- SpecificEntity::SpecificEntity(void) : Entity(0, "", false) {}
- SpecificEntity::SpecificEntity(const signed int& integer, const string& word, const bool& boolean) : Entity(integer, word, boolean){}
- int main ()
- {
- const bool boolean {true};
- const signed int integer {50};
- const std::string word {"Some word"};
- const int entitiesLength {3};
- std::vector<SpecificEntity> entities;
- for (int index = 0; index < entitiesLength; index++)
- entities.push_back({ integer, word, boolean });
- std::cout << "Total number of entities: " << Entity::getEntityCount() << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement