7 Solved Topics

Remove Filter
Member Avatar for
Member Avatar for Seba Sama

Hello, I'm trying to understand some things about derived classes: how to add something "extra" to existing functions in base class. My base class is "shape2D" like a rectangle, 3 functions: set values, calculate, show results. No problem here. Then I create a derived class named "shape3D". Please note the …

Member Avatar for Tumlee
0
349
Member Avatar for tanatos.daniel

I have the following structure: CObject { protected: char *mName; public: CObject(char *n) { mName=strdup(n); } }; CVector:public CObject { char *mValues[50]; int mElements; public: CVector(char *n):CObject(n) {} }; CMatrix:public CObject { char *mValues[50][50]; int mLines; int mColumns; public: CMatrix(char *n):CObject(n) {} }; My main function: int main() { pV=new …

Member Avatar for deceptikon
0
382
Member Avatar for termin8tor

Hey all, I've been programming an ISBN system of sorts and I'm a little stuck (again). I want to output my linked list to a text file, so I setup the code like this: [code] void saveList(char fileName[40]) { for ( list< Publication* >::iterator it = pubList.begin(); it != pubList.end(); …

Member Avatar for termin8tor
0
262
Member Avatar for termin8tor

Hey all, I'm attempting to use an STL List to store a list of objects. Now I realise it's quite trivial to store a list of objects of my own definition. My real question is, how do I fill the list with objects that inherit from a base class. E.g. …

Member Avatar for termin8tor
0
267
Member Avatar for moneypro

#include<iostream> using namespace std; class area { double dim1, dim2; public: void setarea(double d1, double d2) { dim1= d1; dim2 = d2; } void getdim(double &d1, double &d2) { d1 = dim1; d2 = dim2; } virtual double getarea() { cout<<"You must override this functionn"; return 0.0; } }; class …

Member Avatar for moneypro
0
177
Member Avatar for stemiros

Hi, I have a list of base types which stores multiple derived types. The following code shows a simplified setup. [CODE]#include "Base.h" #include "DerivedA.h" #include "DerivedB.h" #include <iostream> #include <list> void main() { std::list<Base*> base; std::list<Base*> *basePointer = &base; for (int i = 0; i < 10; i++) { basePointer->push_back(new …

Member Avatar for mrinal.s2008
0
2K
Member Avatar for manish250

Hello all I have a query,may be silly but i have to clear it.IT IS REGARDING THE UPCASTING.I want to "when we can invoke the methods of base class using the object of derived class.then what is the need of assigning the subclass object to base class reference." I mean …

Member Avatar for JamesCherrill
0
149

The End.