Skip to main content

All Questions

Tagged with
-1 votes
0 answers
31 views

Error inheriting non pure virtual function from class that implement another class

In my code i have this three classes, i'm using the visual studio compiler and it's compiling without any error and runs fine. But i don't need the methodes width and height in my interface IBrick, if ...
Danilo Namitala's user avatar
-2 votes
0 answers
55 views

Is there a way to make my compiler warn if my method-call explicitly calls up to a non-direct-parent superclass? [duplicate]

Background: After some careless refactoring, the following dumb mistake crept into my codebase, resulting in a somewhat-hard-to-track-down runtime misbehavior: class Grandparent { public: void Foo(...
Jeremy Friesner's user avatar
1 vote
1 answer
73 views

How to provide a 'blanket implementation' of a static method for the derived class?

Consider this: struct Base { static Base make() { return {}; } }; struct Derived : public Base { // I _would_ want to have a `static Derived make()` automagically here }; One approach to the ...
Mike Land's user avatar
  • 480
2 votes
1 answer
86 views

How to return smart pointers and covariance in C++

I am following this tutorial to understand how to return smart pointers and covariance in C++. #include <memory> #include <iostream> class cloneable { public: virtual ~...
GPrathap's user avatar
  • 7,650
4 votes
1 answer
94 views

Assign base object without changing inherited ones?

How valid is it to assign a new object to a base one, without changing the inherited ones? The example below works as expected, but is it by chance? This example is simple, but is there any situation ...
T.L's user avatar
  • 684
-2 votes
1 answer
54 views

When calling an inherited method from a derived class it tries to use the uninitialised fields of the base class [closed]

I have two classes. One called Agent, and the other called Player. Agent is the base class and Player is the derived class. When calling the function SetHand() from the derived Player class, I run ...
inThe-FLesh's user avatar
-1 votes
0 answers
34 views

invalid covariant return type for [duplicate]

Consider the following example, which is some part of the bigger codebase, in the getInstance() if I dont return a pointer to the derived class, i.e., just void or int or a different type, the ...
GPrathap's user avatar
  • 7,650
5 votes
3 answers
170 views

Initialization order of inherited constructors

I have this example: #include <iostream> #define print(X) std::cout << X << std::endl struct B1 { B1(int _i = 5): i(_i) { print("B1 constructor"); }; int i; }; ...
mada's user avatar
  • 1,932
1 vote
1 answer
87 views

Inherited functions returning self reference with derived type

I am trying to create a system where one base class has a bunch of functions, then derived classes can inherit it and add more functions. However, all of these functions return the this keyword and I ...
CreeperCrafter979's user avatar
-1 votes
0 answers
56 views

Compiler misidentifying/unrecognising type [duplicate]

I have the following class with constructor: command.h: #include "./robots.h" enum class CMD { //...... }; class CommandTemplate { //..... public: virtual std::unique_ptr<...
steve89's user avatar
1 vote
3 answers
81 views

Inheriting Structs in C++

I am working with the LibAV library, converting it from C to C++ (and moving to an object oriented style). This library has structs to hold data, which need to be created using specific allocation ...
ThomasNotTom's user avatar
0 votes
0 answers
56 views

C++ continue base class bitfield in derived class

I have a base class with a bitfield enum Enum { ENUM1, ENUM2, ... ENUM8 }; struct Base { Enum type : 3; }; I am inheriting a class struct Derived : public Base { bool bf1 : 1; u32 bf2 : 19,...
Evgeny Ilyin's user avatar
0 votes
1 answer
65 views

Calling student method from parent class definition

I'm making an LCD menu and having trouble with the lcdmenu (main menu) and submenu interaction. class submenu; class lcdmenu { protected: command **commandlist; submenu **submenulist; ... ...
Andy Votava's user avatar
0 votes
1 answer
76 views

Abstract function's copy constructor deleted, class inherited from this class gives error

Given header files named Point.h: #pragma once struct Point { double x, y; }; and Shape.h: #pragma once #include "Point.h" #include <vector> class Shape { public: ...
Chris Lee's user avatar
0 votes
1 answer
74 views

Strange inheritance behavior with base class

I hope someone can help me since can't quite understand how it is possible that the following code can work. I have a base class with some classes that derive from it. Each derived class has its own ...
lightimpact90's user avatar

15 30 50 per page
1
2 3 4 5
696