C
Chris
can you assign values to variables like:
int x, y, z = 5;
so that x = 5, y = 5, and z = 5?
thanks for any help!
int x, y, z = 5;
so that x = 5, y = 5, and z = 5?
thanks for any help!
Not in an initializer.Chris said:can you assign values to variables like:
int x, y, z = 5;
so that x = 5, y = 5, and z = 5?
Nils said:Not in an initializer.
You can however do
int x,y,z;
x = y = z = 5;
Not in an initializer.
Chris said:can you assign values to variables like:
int x, y, z = 5;
so that x = 5, y = 5, and z = 5?
thanks for any help!
jimmy said:Nils O. SelÃ¥sdal 写é“:
But in fact it works in an initializer, at least in my VC++.
int x = y = z = 5;
jimmy said:Nils O. SelÃ¥sdal 写é“:
But in fact it works in an initializer, at least in my VC++.
int x = y = z = 5;
can you assign values to variables like:
int x, y, z = 5;
so that x = 5, y = 5, and z = 5?
That's funny, it doesn't work on my g++. Can we talk about Standard C++ now?
Philip
me@here~% cat tmp.cpp
int main(void) {
int x = y = z = 5;
return 0;
}
me@here~% g++ -ansi -pedantic tmp.cpp -otmp
tmp.cpp: In function `int main()':
tmp.cpp:2: `y' undeclared (first use this function)
tmp.cpp:2: (Each undeclared identifier is reported only once for each
function
it appears in.)
tmp.cpp:2: `z' undeclared (first use this function)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.