#include <iostream>
void MyFunction(int, int &);
int main()
{
int number, value;
std::cout << "Please enter a number: ";
std::cin >> number;
std::cout << "How much would you like to multiply it by: ";
std::cin >> value;
MyFunction(value, number);
std::cout << "Your multiplied number is: " << number;
return 0;
}
void MyFunction(int value, int &rNumber)
{
rNumber *= value;
}
This will allow you to change a parameter in a function outside of it's scope.
I want to create another copy of x from the copy constructor, as if I typed: x = new Whatever( y.GetX() )
What exactly do you want x to refer to?
I think x should be Whatever* instead of Whatever& .
Is that so?
Well pointers and references are almost the same thing although in some situations references are just a little cleaner syntax-wise, but anyhing you can do with a reference you can do with a pointer. Although thats not always true the other way around...