0 votes
asked in C++ by

1 Answer

0 votes
answered by (8.2k points)

Be careful when declaring a pointer variable to any type--for instance if you are going to declare a pointer to integer with statement 

int* p; 

and you decide to declare another pointer to integer, you may declare it like this way : 

int* p, q; 

since here the * is associated to the int you may think that what ever variable you declare is a pointer variable. But q is actually an ordinary non-pointer variable here. 

so be careful! You have to write this as: 

int *p, *q; 

Or better yet, just use two lines of code: 

int *p; 
int *q;