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

Cannot implement base class with virtual getters that are defined in child classes

I have a class that is called Object, this class's header is: class DLL_SPEC Object { public: Object(); virtual ~Object(); virtual std::string getString() const; virtual void setString(std::string value); virtual int getInt()…
Antrophy
  • 29
  • 6
-1
votes
1 answer

How do you cast I list in C#?

I am trying to cast a list. public class Base { } public class Item: Base { } Then in another class i have the property requestList1 public List requestList1{ get; set; } Attempts: requestList1 = form.item.Cast() requestList1 = new…
Pomster
  • 14,567
  • 55
  • 128
  • 204
-1
votes
1 answer

Calling a Base Class Construtor in a function of Derived Class

I am trying to call a constructor of a Base Class in a function of Derived Class. Here is the code: Classes: #pragma once #include "CAR_TYRE_DOOR.h" #include using namespace std; //#ifndef 1_A_H_B //#define 1_A_H_B class Honda_Civic:…
Rafay
  • 6,108
  • 11
  • 51
  • 71
-1
votes
2 answers

Can a class contain as a member a Base class which is later specialized to a Derived class?

Can I have a class ("BIG") which has another class as a member (of type "Base"), so that upon construction, this "Base" member will actually be set to a derived class? In particular, I want to have class Base{ public: void…
Wes
  • 35
  • 3
-1
votes
1 answer

I want to add overloaded operators to a derived class

C++ I have been working hard on learning Inheritance and Polymorphism for weeks. I can have Mammals with Dogs and Cats, O can derive Puppy's from Dogs and what not. I have a NaughtleNum base class with a + operator And the derived class is Naughty1.…
-1
votes
1 answer

C++ polymorphism - error passing derived elements to method

as the title says, I'm stuck with polymorphism issue during the developing of my project. I've already searched online but no responses satisfy my doubts. So the situation is the following: defined base abstract class for messages, MessageBase…
panc_fab
  • 522
  • 1
  • 7
  • 24
-1
votes
1 answer

Refactoring code to have base class with just a member common

public class AStreamManager { public IVehicle Vehicle { get; set; } public string AIp { get; set; } public int APort { get; set; } public delegate NetworkStream ConnectToAStream(string host, int port); public…
liv2hak
  • 14,472
  • 53
  • 157
  • 270
-1
votes
4 answers

Is it possible to have a constructor in a derived class also fire code in the base class' constructor?

I was just wondering, I am currently writing a data model in C# for a blog site, and I'm using derived classes. But the annoying thing is, I have to initialize the base class' fields in the derived class' constructor, like below: public class…
TechnicalTophat
  • 1,655
  • 1
  • 15
  • 37
-1
votes
2 answers

C# Base Class forces to create a function in a dependent class but different parameters

I'm creating a long sync process for an app and I don't want to forget something. For each table I have to follow the same procedure but different parameters. It's a long and boring work. For this reason I should have a constraint in the base class…
Enrico
  • 3,592
  • 6
  • 45
  • 102
-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
2 answers

How To Override a base class Method But Auto-Populate The Body Of That Method

I've checked and I'm sure this hasn't already been asked but I have a method in my base class, it's virtual and I override it in my derived class. public MyBaseClass() { public virtual void MyBaseMethod() { return…
Kevin Dark
  • 458
  • 5
  • 15
-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
1 answer

C# List inheritance

Let's say i have a Class called Field public class Field { public string name {get;set;} public string type {get;set;} } For my program, i would need to build a List, but some Field in the List are general and would duplicate in few part…
Mentos
  • 13
  • 6
-1
votes
3 answers

Is it possible to derive from System.String?

I am deriving a class from String, but it won't allow me to inherit from that class. What do I need to do if I want to inherit like this? public class a : string { //class definition }
sujith karivelil
  • 28,671
  • 6
  • 55
  • 88
-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