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
-1
votes
3 answers

How to create an object of a derived class in a base class in c++

Hello I am trying to create a program but am having some trouble I have 3 classes called Goku vegeta Beerus with Goku being the base class and vegeta and Beerus inherting from Goku I want to create an object of vegeta called rose and an object of…
LOLtricker
  • 13
  • 2
-1
votes
1 answer

Cannot convert 'object*' to 'abstract*' in initialization

I am trying to use a server interface to handle multiple servers depending on which one is available. Simplified, the code is like this: Server.h class Server : public ServerInterface { public: Server(); static Server *…
IntiM
  • 11
  • 6
-1
votes
2 answers

upcasting variable in derived class c++

How to change the type of a inherited variable in the derived class? I have the following classes: class Position; class StonePosition; class Position { public: Position() {} }; class StonePosition : public Position { int count; public: …
Nawy
  • 13
  • 1
  • 5
-1
votes
1 answer

My c# derived class can inherit the base class properties and functions, but throws an exception

I have created in my 'main' method an object 'spot' of my base class animal were are 4 properties, a 'Animal' class constructor and a function 'SaySomething'. My object 'spot' passes his parameters to the class constructor 'Animal' for…
-1
votes
2 answers

making base class functions invisible to client

I want to make all functions in my base class invisible to my client, only accessible through my derived class. Is there a way to do this in C++? Thanks!
user3019579
  • 71
  • 10
-1
votes
2 answers

Wrapping an operator[ ] of a private container in derived class

I am trying to implement a wrapping function named: Shape& move_up(int index), that will access and modify1 elements of vector v, in the derived class, named: class Group. I am trying to do that by wrapping the T& operator[](int i) { return…
Ziezi
  • 6,375
  • 3
  • 39
  • 49
-1
votes
2 answers

Derived class that inherits virtual class c++

class vehicle{ ... }; class motorVehicle: virtual public vehicle{ ... }; class twoWheels: virtual public vehicle{ ... }; class motorcycle: public motorVehicle, public twoWheels, virtual vehicle{//(1) .... }; (1) Why does class motorcycle has to…
Kioko Key
  • 119
  • 1
  • 10
-1
votes
2 answers

Can you initialize a derived class with an instance of a baseclass

By that I mean a baseclass, which was not itself initialised using an instance of the derived class. i.e. lets assume it is not an abstract class. class GeomObj{ Colour x; } class Triangle extends GeomObj{ largestAngle y; } GeomObj u; //now…
Marie Simm
  • 13
  • 1
-1
votes
2 answers

Return derived type when return type is base type c#

I have a Base abstract Class and a Derived Class Base abstract class public abstract class BaseData: IListingData { private int? _photos; public string DataKey { get; set; } public abstract List Photos { get; set;…
jaxxbo
  • 7,314
  • 4
  • 35
  • 48
-1
votes
2 answers

Understand classes in Python?

I have to define a class Vehicle. Each object of the class has two attributes, license (license plate) and year (year of construction), and two methods that return those attributes. In addition, I have to define a class Car, a derived class of…
-1
votes
2 answers

Issues calling base class function from derived class

I am currently very new to c++, i have started learning how to use pointers in a path finding algorithm. I am having an issue with calling a function within a class that is derived from a base class. The specific piece of code causing issue…
NAN
  • 3
  • 2
-1
votes
2 answers

Cannot convert from 'char' to 'myClass *'

all. I am trying to write a linked list of pointer objects. Upon changing obj to obj* , the compiler began to complain about my initializer constructors, claiming: a) Error C2078: too many initializers b) Error C2440:…
user107680
  • 81
  • 1
  • 8
-1
votes
2 answers

vector< unique_ptr > as base class member

I have three classes: Class Something {...} Class A { public: A(); virtual ~A() = 0; //have also tried this as non-abstract std::vector< unique_ptr > somethings; //have tried this just as std::vector as…
zmartin
  • 211
  • 1
  • 2
  • 7
-1
votes
2 answers

.Net Extension method for derived class (TreeNode)

I have a treeview, and want to simply return the deepest node that satisfies a given condition. The answer to this question is the most promising so far: Searching a tree using LINQ So I could do this: foreach(CustomTreeNode aNode in…
user1830285
  • 578
  • 8
  • 24
-1
votes
4 answers

Procedure in derived class doesn't return derived object

I have a base class in C# like: public class A{ public A something() { //... } } And a derived class like: public class B:A When I do: B obj = new B(); obj = obj.something(); VS throws an error saying (something like) "A can't be…