int create(int number, vector<string>& status_list)
{
//vector<string> status_list; Not needed.
// What is with all the magic numbers?
if(number < 10) {
status_list.push_back("small");
} elseif (number > 100) {
status_list.push_back("big");
}
number -= 11;
if(number < 0) {
number *= -1;
status_list.push_back("subtraction, it is negative");
} else {
status_list.push_back("subtraction, it is positive");
}
if((number % 2) == 0) {
status_list.push_back("even number");
number /= 2;
}
// status = &status_list; // Not needed.
return number;
}
Edit: and main()
1 2 3 4
vector<string> output; // No need of the "empty" initializer vectors are empty by default.
int number = create(17, output);
int byvalue( int a ) {
a = 42; // will not affect the caller
}
int byref( int& a ) {
a = 42; // modifies caller's variable
}
int byvalue( int* a ) {
int b;
*a = 42; // modifies caller's variable
a = b; // will not affect the caller, a points to b
}