variable return type in c++ class

前端 未结 7 1729
花落未央
花落未央 2021-01-25 08:33

i have a class with the following structure:

class myClass
{
    private:
        int type;
        classOne objectOne;
        classTwo objectTwo;
    public:
          


        
7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-25 08:56

    ClassOne and ClassTwo need to have the same return type then either via inheritance or composition. i.e ClassOne and ClassTwo need to be subclasses of the same super class OR they need to impl the same interface.

提交回复
热议问题