Category : inheritance

having this base class: Core.hpp: #ifndef C3_CORE_HPP #define C3_CORE_HPP #include <c3/utils/Str.hpp> #include <c3/utils/Vec.hpp> #include <c3/school/Student.hpp> class Core { public: Core() = default; explicit Core(std::istream&in); virtual ~Core(); virtual double grade() const; const Str &getName() const; double getMidterm() const; double getFinal() const; const Vec<double> &getHomeworks() const; protected: Vec<double> homeworks; virtual std::istream &read(std::istream &in); virtual Core *clone() const; ..

Read more

I want to derive from mlpack::ann::FFN, override the function FFN::Forward(arma::mat inputs, arma::mat& results) but still be able to use the overloaded function FFN::Forward(arma::mat inputs, arma::mat& results, size_t begin, size_t end). I have read about name hiding and why it happens, and that the way to resolve the issue is to use using declaration to include ..

Read more

I want to derive from mlpack::ann::FFN and override the function FFN::Forward(arma::mat inputs, arma::mat& results) but still be able to use the overloaded function FFN::Forward(arma::mat inputs, arma::mat& results, size_t begin, size_t end). I have read about name hiding and why it happens, and that the way to resolve the issue is to use using declaration to ..

Read more

I am trying to set up a kinda double polymorphic map in C++. I have something like this: class Base{ }; class Derived : Base{ }; template <typename T> class ClassTemplate{ std::vector<T> vec; }; class TemplatedBase : ClassTemplate<Base>{ }; class TemplatedDerived : ClassTemplate<Derived>{ }; I want to create a function that takes in a std::map<std::string, ..

Read more

I have two classes: struct Base { int a; }; template<typename T> struct Derived : Base {}; Are they layout compatible or not? C++11 standard says ([class.mem]/16): Two standard-layout struct (Clause 9) types are layout-compatible if they have the same number of non-static data members and corresponding non-static data members (in declaration order) have layout-compatible ..

Read more

I have this base class: class LevelPlayer { protected: int level; int id; public: LevelPlayer():id(-1){} LevelPlayer(int level,int id):level(level),id(id){} virtual ~LevelPlayer()=default; LevelPlayer(const LevelPlayer&)=default; LevelPlayer& operator=(const LevelPlayer&)=default; }; and this derived class: class GroupPlayer: public LevelPlayer { private: IdPlayer* ptr; public: GroupPlayer():LevelPlayer(),ptr(nullptr){} GroupPlayer(int level,int id,IdPlayer* ptr):LevelPlayer(level,id),ptr(new IdPlayer(*ptr)){} ~GroupPlayer()override=default; GroupPlayer(const GroupPlayer&); GroupPlayer& operator=(const GroupPlayer&); }; and for the ..

Read more