I am having trouble in returning multiple types. I know there are a few people who had trouble with this but mine is different. I'm using header files and they're not. So here is my code.
//in Fruit.h
#include <string>
using namespace std;
class Fruit {
private:
string Fruitname;
int Fruitamount;
public:
Fruit(string name, int amount);
int getFruitStats();
~Fruit();
};
in the C++ file
//in Fruit.cpp
#include "Fruit.h"
#include <tuple>
Fruit::Fruit(string name, int amount)
{
Fruitname = name;
Fruitamount = amount;
}
tuple<string,int> Fruit::getFruitStats() {
//^this one causes the problem
}
Fruit::~Fruit()
{
}
The error messages as follows:
- declaration is incompatible with int Fruit::getFruitStats
- Error C2556 'std::tuple Fruit::getFruitStats(void)': overloaded function differs only by return type from 'int Fruit::getFruitStats(void)'
- Error C2371 'Fruit::getFruitStats': redefinition; different basic types
I tried changing the Fruit.h's getFruitStats type to integer, string, void but apparently I'm missing something here. Can anyone help me?
Aucun commentaire:
Enregistrer un commentaire