C++ Topics and Explanations
C++ multiple inheritance problem

[ Follow Ups ] [ Post Follow Up ] [ C++ Topics and Explanations ]

Posted by lee coper on March 04, 204 at 23:26:48:

In Reply to: C++ multiple inheritance problem posted by jinyoung jang on February 07, 202 at 21:48:10:

No way to go... just go back and sleep

: I want to use a class composed of all pure virtual functions as like 'interface' in java, but instantiating the interface class is not allowed in C++. like following code.

: in C++,

: class ISampleProvider{
: virtual CObject getSample() = 0;
: }

: class A : public CObject, public ISampleProvider{
: method A...
: mehtod B...

: // implementation for ISampleProvider
: CObject getSample(){
: return m_thisSample;
: }
: }

: void main(){
: A *a = new A;
: ISampleProvider *sample =
: dynamic_cast(a);

: if(sample)
: sample.getSample(); // error occurs
: }

: It's so powerful expression in java, but C++ does not support it. I think.

: I wanna know that this is essential feature of C++ or another exprssion or technique exists.

: thank you.




Follow Ups:


Post a Follow Up:

Name:
E-Mail:

Subject:

Comments:


[ Follow Ups ] [ Post Follow Up ] [ C++ Topics and Explanations ]