I have tried to implement properties in an "interface"
interface IPolygon
{
__declspec(property(get = _GetArea)) double area;
virtual double _GetArea() const abstract;
};
class CPoly : public IPolygon
{
public:
CPoly(.....) { ......}
protected:
virtual double _GetArea() const override { return .. calculation of area ... };
}
.. somewhere in code:
CPoly mypolygon;
double xarea = mypolygon.area;
...
But when using the CPoly-class the linker! says that IPolygon::_GetArea() is not implemented yet. Then changing
interface IPolygon
{
__declspec(property(get = _GetArea)) double area;
virtual double _GetArea() const { return this->_GetArea(); }
};
calling the getter in the "interface" it will work
but this it not the way it should be ...
Is there a way to define abstract property getters and setters or abstract properties? to get the interface similar to c#.
(this is NOT a question wether it makes sense to use propertis in c++ anyhow!)
What I have tried:
Have tried the above codes and variants
Have debugged b step and when implemnting anything in the virtual fundction in IPolygon (instead of abstract),
the debugger steps into that function and not into the inherited class function (so IPolygon::_GetArea() is called instead of CPoly::_GetArea() )