Category : abstraction

I’ve got the following class structure where AnotherPlayer is the child of SomePlayer. I have the method getInternalMove implemented in SomePlayer and overridden it in AnotherPlayer. It is called inside getMove. But when I call AnotherPlayer::getMove it doesn’t call getInternalMove in AnotherPlayer. What am I missing? According to this question, it should call `AnotherPla Note: ..

Read more

My code: Animal.h #ifndef ANIMAL_H #define ANIMAL_H #include <Cat.h> #include <iostream> using namespace std; class Animal { public: Animal( ); void setName(string n); virtual string getAnimalType(); //abstract method string getName(); virtual void makeNoise();//abstract method private: string name; }; #endif // ANIMAL_H Animal.cpp #include "Animal.h" Animal::Animal() { } void Animal::setName(string n) { name=n; } string Animal::getName() ..

Read more

According to what I have learned, Abstraction is a concept of hiding internal implementation. We can achieve abstraction in java with interfaces, abstract keyword(for class/method) as well as through methods. eg Scanner s = new Scanner(System.in); int x = s.nextInt(); Here we need not know anything about nextInt() method. So I can say this is ..

Read more

The More General Question I am wondering if there is a standard way that operating systems / desktop managers use to expose the user’s preference regarding the placement of the window frame controls (Close, Maximize/Miniaturize, Minimize). For platforms like Windows and MacOS, it’s "pretty" safe to assume that the users wants their window controls on ..

Read more

Let’s say I have the following class: template <typename T> class SomeClass : Parent<T> { public: // I have a function such as this one: T DoSomething(const T &t) { return t.DoSomething(some_data); } // But `T` might be a pointer, so sometimes I will need something like the following // instead (which obviously doesn’t work ..

Read more