Hi.
Conventionally speaking, do you declare and initialize variables at the beginning of a function or loop or right before usage.
For example:
int main()
{
char temp;
cin >> temp;
cout << "1234... & " << temp;
cin >> temp;
cout << temp;
int x;
cin >> x;
cout << temp << " & " << x;
return 0;
}
The arbitrary code above depicts declaration of variables right before usage (int x).
Which way is most convention is arguably better?
Thanks,
Kuphryn