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
-2
votes
2 answers

Get derived class properties in base Static method - RIDDLE! :)

I wanted to elaborate on the current project i'm working on but that would be kind long. Instead I'll just post a programming riddle which basically explains what i'm trying to accomplish. :) abstract class A { // key = Derived Class name, value…
JarJarrr
  • 400
  • 3
  • 18
-2
votes
2 answers

C# dictionary lookup using derived class

I think this could be a common question but I failed to find any post about it. I'm writing some pseudo code below. If you want to compile the code, please just ignore this post. So say two classes: one base class and one child class. NOTE: both…
Karl Jr.
  • 15
  • 4
-2
votes
1 answer

How to instatiate a derived class instead of its base

This is my problem: I have a Class A that is used (instantiated) several times within a Class B. I need to change the behaviour of the Class A, mainly the constructor, and then I derived it with Class C. Class C: Class A I would like that Class B…
-2
votes
2 answers

How to create a new pointer to a derived class which type is unknown at compile time in C++?

I have a code where there are some pointers to derived classes of the same base class. At one point I need to create another pointer to one of this derived classes, but I don't know at compile time to which class it will point to. Here an example of…
Mattia
  • 135
  • 3
  • 13
-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
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
3 answers

C++ member access from a derived class of a templated type

Long story short, what I want here is to declare a templated type in a base class and be able to access that type A such that the base class B contains it and the derived class C is able to access it as C::A. I did try declaring an int inside…
pandoragami
  • 5,387
  • 15
  • 68
  • 116
-2
votes
1 answer

Read an attribute of the base class using "istream" of derived class

It looks like Coord(a) doesn't work , and the values for lon and lat are 00.0000 and 00.0000, those from the default constructor . What should I do? Ia there a problem with the syntax ? Isn't it in >> Coord(a) to read lon and lat from base class? …
Mihai
  • 101
  • 2
  • 2
  • 8
-2
votes
1 answer

How do I make a constructor for a derived class?

I am trying to make a constructor for a derived class. Doing it this way doesn't seem to work: #include class FirstClass { public: int X; FirstClass(int x) { this->X = x; } int getXpow() { return pow(X, 2);…
Alex Azazel
  • 332
  • 5
  • 18
-2
votes
2 answers

Vehicle Object Array - C#

I'm having trouble writing up some code. I'm not too sure where and how to write up the constructors and the accessors. The activity I have to do is this: Write 3 derived classes to allow a user to enter the details of three types of Vehicles with…
SlavisaB
  • 31
  • 1
  • 1
  • 7
-2
votes
4 answers

Display Method - Output Error

I am beginning to learn JAVA. I was asked to create a Car Program that tracks new and used cars. I am supposed to create a super class called car, two derived classes called UsedCar and NewCar, and a Driver class that tests those 3 classes. All the…
Fryguy
  • 17
  • 4
-2
votes
2 answers

Initialize derived class?

In header: class foo : public ISceneNode { public: foo(){} void setAge(int a) { age = a; } int getAge(){ return age; } private: int age; } In source: foo::foo() :ISceneNode(0,0) { age = 5; } For example, I have this class with…
Cobra
  • 63
  • 1
  • 7
-2
votes
2 answers

I am Totally lost Using Derived Classes in C# Visual 2010

This Is my Assignment, I am having Troubles Getting my Class To Work With main for, Can Someone please Help Me, This is due on Tuesday and I have been hitting a brick wall in every approach I have tried. all my class and my forms are posted. Please…
ErickBRCC
  • 1
  • 5
-2
votes
1 answer

derived clases in different files c++

How I do to make a main class in file_x.h, and file_x.cpp and then a derived class from the class made in file_x, in file_y.h and file_y.cpp I have tried lots of things without any good results, Could you please give me an example with both classes…
newtonis
  • 47
  • 1
  • 8
-2
votes
2 answers

method overriding and method hiding

Possible Duplicate: C#: new versus override class BaseAppXmlLogReaders { public virtual void WriteLog() { } public void Add() { } } class DerivedAppXmlLogReaders : BaseAppXmlLogReaders { …
ND's
  • 2,155
  • 6
  • 38
  • 59