
Posted by jinyoung jang on February 07, 202 at 21:48:10:
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: