Can two variables of same type be declared/defined in one line?

I am a Fortran user for most of my life. In Fortran we do this:
 
int x, y


When using C++, can I declare two variable of same type in just one line like below?

 
int x, y;


Thank you!
Yes.

Take care, though, as this can catch you up:
int * x, y;
x is an int pointer and y is just a regular int.
Yes you can... and since pointers are variables too be careful with the asterisk... if you don't want to get confused do this: int *x, y; that way will be better because if you do this: int* x,y; it will be the same but it might confuse u...
LB and danoc93,

Thanks a lot for your guys' comments.

I am clear now with what I asked. But I am now confused by the topic introduced by LB.

1. What does int * x, y; mean? Two pointers to int type or one pointer to int and one int?

2. Why do you guys think int *x, y; is more understandable than int * x, y; and int* x, y;???

Thanks!
1) It is effectively the same as:
1
2
int* x;
int y;


2) Just do whatever you like. I do int* x; but if you are working with code that does something different then don't force it.
Thank you, firedraco!!!!!!!!!!!!!!!!!!!!!!!!
Topic archived. No new replies allowed.