variable return type in c++ class

前端 未结 7 1732
花落未央
花落未央 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

    The first problem is how you will determine the class of which type has been returned. I think it is possible to return a pointer to structure of this type

    struct res {
      myClass* c1;
      ClassOne* c2;
    } ;
    

    The field of the not chosen class is NULL, the other points to the object.

提交回复
热议问题