Questions tagged [derived-class]

In Object Oriented languages, derived class can inherit properties and/or member functions from a base class, also called super class. cf inheritance and polymorphism.

In Object Oriented languages, derived class can inherit properties and/or member functions from a base class, also called super class. cf inheritance and polymorphism.

1192 questions
-4
votes
1 answer

C++: Using function calling Derived class in Base class

How do I use Derived class in Base class? EDIT 2: When calling virtual void move(Derived1 &race); in main, it doesn't compile, but throws error that Derived1 is not found. When I to call the function without the Derived1 class object, it does…
randomehh
  • 27
  • 8
-4
votes
2 answers

Is it safe to dereference a downcasted derived object via make_unique?

I have a base class and a derived class along with a function that returns a reference to the base class. Is it safe to use make_unique and then downcast the pointers? I am trying to avoid a copy operation. class Animal {} class Dog : Animal…
user3072517
  • 513
  • 1
  • 7
  • 21
-5
votes
2 answers

C# Generic and Derivation

I've been digging through several posts on this subject and could not find any suitable answer to the following problem… can anyone tell me why this does not compile : class MyItem { public int ID; } class MyList { public List
-5
votes
2 answers

C++ using derived class variable in base class

The below is my code design class D; class A { D *d; class B:public C { somefunctions(); } } class C { //I need to use class D variables inside Class C } Whatever I do inside the Class C for bringing Class D variables, it is…
Paiya
  • 7
  • 3
-6
votes
1 answer

Derived classes C++ BankAccount program

I'm trying to make a BankAccount class with derived a class CheckingAccount. The problem I'm having are as follows: CheckingAccount should contain a data member to keep track of the number of withdrawal transactions made on the account. Whenever a…
Michael Libman
  • 73
  • 1
  • 10
-8
votes
5 answers

c# get field (property) values of derived class in base constructor

I have 2 classes: public class Class1 { private string Name1; public Class1() { //How to get Name2 of the derived class? } } public class Class2 : Class1 { private string Name2 = "asd"; public Class2(){} } How to get…
user2153759
1 2 3
79
80