This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Question on derived class?
- From: "Pradip Singh" <pradip dot singh at lgsoftindia dot com>
- To: "Ishwar Rattan" <ishwar at pali dot cps dot cmich dot edu>,<gcc-help at gcc dot gnu dot org>
- Date: Fri, 19 Nov 2004 16:14:44 +0530
- Subject: RE: Question on derived class?
Hi All,
It is possible to access a->reset() by runtime polymorphism concept in c++. But in ur code the assignment A *a = b is wrong. It should be A *a = &b; But I donot know what u mean by pure virtual class. If it is a class contianing some pure virtual methods then it is called abstract class. And remember to define the pure virtual functions in A in b. Otherwise B will also become abstract class and u cannot create its object. So the very statement static B b; will start throwing compilation error.
But this is not the right forum to ask such question. Find some other C++ forum.
thanks and regards,
Pradip
-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
Behalf Of Ishwar Rattan
Sent: Friday, November 19, 2004 5:40 AM
To: gcc-help@gcc.gnu.org
Subject: Question on derived class?
Assume that A is pure virtual class with some public
methods.
B is derived from A
Class B : virtual A {
public:
// all methods of A are defined here +
A new method is also defined (here only)
-- call it reset()
protected:
// ...
};
Now B is initiated as
static B b;
A *a = b;
Is it possible to access b.reset() using a->reset()?
-ishwar