Category : abstract-class

I have in my task 4 classes: a) Person (abstract class with one pure virtual method show and pure virtual destructor) b) Gunslinger (inherits virtual from Person) c) PokerPlayer (inherits virtual from Person) d) BadDude (inherits from both Gunslinger and PokerPlayer classes) Code of all classes: Person.h #ifndef PERSON_H_ #define PERSON_H_ #include <string> #include <iostream> ..

Read more

I want to have a class containing a vector of shared pointers to an abstract class, which on runtime will be derived class objects. Here’s the abstract class: #pragma once #include <string_view> #include <string> using std::string_view; using std::string; class Someone { private: string _name; unsigned _skill; protected: Someone (string_view name, unsigned skill) : _name{ name ..

Read more

I’m doing a graph ADT https://github.com/atomind2005/Vectors-Graph-Theory-Implementation When I run graph.addVertex(0), graph.addVertex(1), etc all the way to graph.addVertex(9), it works, but when I run for(int x =0; x < 10; x++){ graph.addVertex(x); } however big the number may be on the for loop, it always throws a segmentation fault. I have no clue why this is ..

Read more