How do you return two values from a single method?

后端 未结 22 837
谎友^
谎友^ 2020-12-11 00:58

When your in a situation where you need to return two things in a single method, what is the best approach?

I understand the philosophy that a method should do one t

22条回答
  •  情话喂你
    2020-12-11 01:37

    Use std::vector, QList, or some managed library container to hold however many X you want to return:

    QList getMultipleItems()
    {
      QList returnValue;
      for (int i = 0; i < countOfItems; ++i)
      {
        returnValue.push_back();
      }
      return returnValue;
    }
    

提交回复
热议问题