Questions tagged [base-class]

In Object Oriented Programming, a base class is one from which other classes inherit. For example, a child-class `Male` and another child-class `Female` may both inherit from the base-class `Human`.

In Object Oriented Programming, a base class is one from which other classes inherit. For example, a child-class Male and another child-class Female may both inherit from the base-class Human. As a result of such an inheritance, each of them will have at least all the attributes and methods of the class Human and perhaps a few others.

678 questions
-1
votes
2 answers

Issues with Inheritance C++ Qt Project

I have a QT Project where I've been given a UML diagram and some instructions (See below) I've been so lost as to what I'm doing so I'm just going to show all my code, it's finished but not working... The main error I get now is the Constructors…
Barry Michael Doyle
  • 9,333
  • 30
  • 83
  • 143
-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…
-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
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…
-1
votes
5 answers

I need to make a vector containing objects of a base class and a derived class and know which element is which

I am working on a game that has monsters and dragons. Dragons can do everything monsters can do except they can also breathe fire. I have made a class of type 'monster' and a class that inherits from monster called 'dragon'. I then have a class…
-1
votes
1 answer

Inheriting base class, defining the base class' prototype method but calling child class' method from third object

I have a class called "Game", with prototypes functions "Update" and "Draw" but they're not defined. It's up to the object inheriting the "Game" object to override them. Is this possible? Contents of "Game.h" class Game // does it have to…
Deukalion
  • 2,516
  • 9
  • 32
  • 50
-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
1 answer

Python - set class var from a private static method

I've written the following base static class in python: from abc import ABC,abstractmethod import typing from main_module import utils class BaseCLS(ABC): credentials = None # <--- I want to set this var def __init_session(caller) ->…
Shlomi Schwartz
  • 8,693
  • 29
  • 109
  • 186
-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

Accessing the user object in a base controller in Laravel 7?

I have a base controller:
rockstardev
  • 13,479
  • 39
  • 164
  • 296
-2
votes
2 answers

How to create a subclass object in the baseclass

what I am trying to do is: Have a Sub class object in Base class. Make Sub class access Base class'es variables Base.h #include "Sub.h" class Base { Sub subobject int x; } Sub.h #include Base // to acces x from .cpp file class Sub: public…
Stel Team
  • 77
  • 9
-2
votes
1 answer

Inheriting a method from a base class (vehicle) and value from a derived class (car) to implement in another derived class (lane) using C++

I have a problem regarding inheritance on C++. The Vehicle class has SetStartingPosition() and GetStartingPosition() functions. The Car class inherits these functions and sets the starting position to 5 in the constructor with…
L. Howard
  • 19
  • 2
-2
votes
3 answers

One base class for both forms and user controls

I have a Form with several methods for input validation. I want this validation logic to be shared between several Forms and UserControls. What should be the type of the base class? It cannot be Form since it will also be used for UserControls and…
Michael Haddad
  • 4,085
  • 7
  • 42
  • 82
-2
votes
1 answer

What is the point of initializing a base class object as a derived class object

If I want to initialize a class Square class Square : public Rectangle { public Square(int length) { this->length = length; this->width = length; } } derived from a class Rectangle class Rectangle { protected int…
po0l
  • 98
  • 8
-2
votes
2 answers

Difference between passing arguments to the base class constructor in C++

What is the difference in passing arguments to the base class constructor? Dog::Dog(string input_name, int input_age) : Pet(input_name, input_age) { } Dog::Dog(string input_name, int input_age) { Pet(input_name, input_age); }