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
1 answer

Pointer to function of derived class withing parent class

Currently I'm learning Win32 and C++ and I finished my first application. Now I want to translate the code from functional style to OOP. Here is a shortened version of my code: #include class BaseWindow { public: BaseWindow (); …
Cubi73
  • 1,891
  • 3
  • 31
  • 52
-1
votes
1 answer

C++: Inheritance priority

This is a simple question (I think). I'm just not sure about it and I'm looking for a good solution too :) Let's say I have this: class Base { public: virtual ~Base() {} virtual Base& connect(Base &b) = 0; } class Derived: public Base { …
makeMonday
  • 2,303
  • 4
  • 25
  • 43
-1
votes
1 answer

inherited objects in c++ and loss of attributes

I have : class A { public: A(); ~A(); void addClass(int id, C class); C getClass(int id); private: hash_map map; //TEMPLATE }; Let's say C is a parent class. Is there any way in the main method to use the method…
Theriotgames Riot
  • 333
  • 3
  • 6
  • 14
-1
votes
1 answer

How do I use the MemberwiseClose() method in C#

In a building-navigation program I am working on, my group uses a Room class made out of Tile objects. I want to find a way to data-bind the information of the room into an information bubble that pops up during a mouse enter event. What I am…
Karl Thompson
  • 65
  • 1
  • 7
-1
votes
5 answers

How can I make a class both implement an Interface and inherit from another class

I want my class to implement an interface and also get the additional properties from Auditable table. Can I do both? I have tried to do it here but I am getting an error in my IDE. public partial class ObjectiveDetail : IEquatable,…
Alan2
  • 23,493
  • 79
  • 256
  • 450
-1
votes
2 answers

c++ no matching function for call to base-class method from derived-class

I got a little confused as gcc dropped an error with the message error: no matching function for call to ... note: candidates are ... So I did a wrong function call as it seems to be. Here is what I really got from…
-2
votes
2 answers

How do I overload a function with a parameter with a type that is a child class of the base parameter?

If I have a base abstract class with a function that takes it's own class as a parameter: class Component abstract { public: virtual bool Method(Component& other) = 0; }; And I have a child class which overrides and overloads this function to…
-2
votes
1 answer

Why can you return Task when Task is expected?

As I was messing with tasks, I made a private static async method that returns a random number after a delay. I had also made a public static method that calls the private static async method, but I had forgotten to change the return type from Task…
so_as
  • 41
  • 6
-2
votes
2 answers

I'm not sure what I'm doing wrong on this program

Define a Course base class with attributes number and title. Define a print_info() method that displays the course number and title. Also define a derived class OfferedCourse with the additional attributes instructor_name, term, and class_time. Ex:…
Jay
  • 1
-2
votes
2 answers

What is the purpose of defining an interface type variable instead derived class type?

I will explain my issue with this example: ICollection listOfEmployee = new List(); //listOfEmployee = Some code; In C#, List inherits from IList, ICollection, IEnumerable, IEnumerable, IList, ICollection,…
Hgrbz
  • 185
  • 3
  • 12
-2
votes
1 answer

Python multiple inheritance confusion

I've been trying to understand how to make sure all super().__init__()s run when writing a class that inherits from two unrelated classes. Based on answers such as this and others like it, calling super(DerivedClass, self).__init__() should do the…
lte__
  • 7,175
  • 25
  • 74
  • 131
-2
votes
1 answer

Please explain the outcome of Shape r = new Square() and why Square's methods aren't available

I'm working through Jeff Fritz's c# tutorial videos, and there is some code like this that uses an abstract class: public abstract class Shape {} public class Rectangle : Shape {} public class Square : Rectangle { public string…
EvilDr
  • 8,943
  • 14
  • 73
  • 133
-2
votes
1 answer

Why cant i use base constructor in c#

let's say we have two classes class baseClass { public baseClass() { } public baseClass(int value) { } } class derivedClass { } is there a way to call the parametrized constructor from derivedClass like derivedClass…
-2
votes
2 answers

assign different derived classes to base class based on condition

I have a base class and two derived classes: public class base1 { public int property1; } public class child1 : base1 { public int property2; } public class child2 : base1 { public int property3; } when I assign newProp variable like…
z.k
  • 45
  • 1
  • 8
-2
votes
1 answer

How to create derived class with "derived input class"?

I have a base class class BaseClass { public: BaseClass(const >& input) } I would like to create derived class so that the input they take must be derived from inputClassForBase, e.g.: …
PF Chang
  • 47
  • 6