RE: Question on derived class?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx]On
Behalf Of Ishwar Rattan
Sent: Friday, November 19, 2004 5:40 AM
To: gcc-help@xxxxxxxxxxx
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




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux