I see a few things that need some help here I'll go over them quickly
1)
string compare2() {return (test1);}
This seem to be a getter function for your class. With getters and setters always label them so people know what they are. For example since this is a getter you should have something like this
string getString() {return test1;}
That way when other people read your code it is much easier for them to understand. Also you don't seem to be using this anywhere, but it could be for something you plan to do in the future.
2)
if(input == input )
Like DTS was explaining earlier this code will always be true no matter what. From your comments it seems like you mean to change it later, but just in case I want to explain what it does a bit further.
This statement is essentially the same as saying
if (1 == 1)
. So whenever you run that if statement it will always be true since 1 is always equal to 1.
3) This doesn't seem to be in your code anymore but figured I would go over it.
string compare2() {return (test1, test2, test3);}
The reason why this is wrong is because functions can only ever return 1 thing at a time by the return statement.
Now if you do want to alter more then 1 variable you can use multiple different techniques to do so. One would be to use references (&)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <iostream>
using namespace std;
// Change multiple variables without returning
void changeAllToOne (int &a, int &b, int &c);
int main()
{
int one = 10;
int two = 20;
int three = 30;
// Changes all three variables that I pass to 1 without returning anything
changeAllToOne(one, two, three);
cout << one << two << three << endl;
return 0;
}
// Notice the & operator.
void changeAllToOne(int &a, int &b, int &c)
{
a = 1;
b = 1;
c = 1;
}
|
When you put the reference operator in a parameter you are telling the function to alter whatever variable you pass in directly instead of creating a temporary copy of the variable that gets destroyed after the function is done. You can find more about this in the tutorials on here.
But what it seems like you were trying to do with your triple return statement was to use it as a getter for all 3 private variables in the class. This is illegal because you can only return 1 thing at a time, so you will have to make a getter for each variable in your class.
Hope this helps a bit and good luck with your program, glad to see you like the vectors also :)