Quick question here, or at least hopefully so. I was just going through the tutorials ag, and writing myself simple programs for examples for the future. So I was just thinking a bit, and wrote up this program:
Code:
#include <iostream>
using namespace std;
int main()
{
int *pointer;
int x;
int answer;
pointer = &x;
cout<<"Insert a whole number: ";
cin>> x; // Makes x = Number you said
cin.ignore();
cout<< "The number you chose is: ";
cout<< *pointer; // Uses the pointer function, which points towards "x"
cout<< "\nThis number multiplied by 5 is: ";
answer = (*pointer * 5); // Multiples x by 5, but using pointer
cout<< ""<< answer <<""; // Shows answer
cin.get();
return 0;
}
And the code works nicely. It basically multiplies whatever the person said, by 5. Simple. The question is, is this any faster, then actually doing x * 5? I recognize that using pointers will "grab" the said value faster, as all it has to do is point towards it, rather then actually grabbing it. Is the above true while using the variable in other things, such as multiplication?