
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(){ : if(sample) : 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.
: A *a = new A;
: ISampleProvider *sample =
: dynamic_cast
: sample.getSample(); // error occurs
: }
Post a Follow Up: