Skip to main content

All Questions

2 votes
1 answer
85 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
3 votes
1 answer
48 views

Multiple constructors annotated with Lombok @Builder cause a problem?

This is my first question, so please feel free to correct anything that I missed writing this question:) I am having trouble with using the @Bulider with my DTO objects. I have an abstract class "...
Doh Kun Lee sanity's user avatar
-2 votes
0 answers
55 views

a constructer declared in a type with parametere list must have 'this' constructor inisializer error [closed]

I'm working on a C# project where I have an abstract base class Employee with a parameterized constructor Employee(string name). My derived class FullTimeEmployee has a constructor that takes three ...
Smoker's user avatar
  • 1
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 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
1 answer
49 views

Constructor parameter is null until parent is not initialized

Look at the following code: abstract class A { init { f() } abstract fun f() } class B(val p: () -> Unit) : A() { override fun f() { try { p() ...
Alexey's user avatar
  • 3,182
-1 votes
2 answers
102 views

C# Initialize inherited record form base record

I have a base record type and an inherited record type which adds a few fields. At runtime I have an instance of the base record type and want to convert it to an instance of the inherited record type,...
Hothie's user avatar
  • 109
1 vote
0 answers
19 views

Constructor-chaining, order of parameters?

You know you can chain constructor calls: class A { function constructor() { } } class B extends A { function constructor() { parent.constructor(); } } but there can ...
John Smith's user avatar
  • 6,097
-1 votes
1 answer
48 views

Inheritance in Java and its confusing things [closed]

class A { public void m() { System.out.println("A.m"); } public void n() { System.out.println("A.n"); } } class B extends A { @Override ...
2uys's user avatar
  • 1
1 vote
2 answers
83 views

Is it allowed to pass "this" of derived class to constructor of base class?

Here is the code I originally wanted to write: class A { public: A(someType someData) { this->init(someData); } virtual void init(someType) = 0; } This is not allowed, ...
Reverent Lapwing's user avatar
-1 votes
2 answers
107 views

Inheritance - is it possible to 'force' variable values relative to the derived class?

I am trying to create a simple model. A vehicle can only ever have 1 VehicleType, and a VehicleType is a Vehicle. As such I have created a base class Vehicle, and three derived classes Bike, Car, and ...
Phil's user avatar
  • 29
0 votes
0 answers
58 views

Why is base constructor available via curly braces but not via parentheses? [duplicate]

I've come across the following issue. Here is a simple piece of code: struct Base { Base(int x) : x_{x} {} int get() { return x_; } private: int x_ = 0; }; struct Derived : Base {}; int main(...
Kaiyakha's user avatar
  • 1,653
0 votes
0 answers
62 views

Initialize a struct with a const default through copy

I was trying to define a AbstractOptions struct that would hold some options that are used later on for a different class Operator with a concrete implementation ImplementedOptions. As a default value ...
Robert Deibel's user avatar
-1 votes
1 answer
54 views

Bunch of errors that aren't valid, probably because of formatting but I can't crack it

public class TicketTest { int serial; public static void main(String args[]) { int total_sales = 0; new WebTicket(10); new WebTicket(5); ...
Corrupted_RainbowGuy's user avatar
0 votes
2 answers
83 views

Create object of subclass by object of superclass [python]

there is way (in python) to create subclass obj by superclass obj? I have to parse a file so I have to: open file and parse => superclass obj try to extend file if conditions are good => ...
petunia rose's user avatar

15 30 50 per page
1
2 3 4 5
105