Is there any difference between dlearations int* x and int
*x? If so tell me the difference?

Answers were Sorted based on User's Feedback



Is there any difference between dlearations int* x and int *x? If so tell me the difference?..

Answer / prasant

Reejusri is correct....
VC++ compiler complains with error
"error C2440: '=' : cannot convert from 'int' to 'int *'
1> Conversion from integral type to pointer type
requires reinterpret_cast, C-style cast or function-style
cas" for the following code

int *x,y,z;
x=y;

So, there is a difference.

Is This Answer Correct ?    0 Yes 2 No

Is there any difference between dlearations int* x and int *x? If so tell me the difference?..

Answer / reeju srivastava

There is no diffrence between int* x and int *x.
but difference will come into picture when you use:

Case 1:
int* x,y,z;

and

Case2:
int *x,y,z;

in first case x,y and z are integer pointer, where as
un second case only x is integer pointer rest y and z is
integer. So its always a good practice not to put multiple
variable in single line.

Is This Answer Correct ?    15 Yes 21 No

Is there any difference between dlearations int* x and int *x? If so tell me the difference?..

Answer / ramesh

ya...it is compiler dependent...it is good pracicce to give as
int *x;

Is This Answer Correct ?    7 Yes 15 No

Is there any difference between dlearations int* x and int *x? If so tell me the difference?..

Answer / kris

yeah no difference, only matters if we declare 2 or more
variables in the int* a,b,c kind of thing,

chai

Is This Answer Correct ?    0 Yes 10 No

Is there any difference between dlearations int* x and int *x? If so tell me the difference?..

Answer / reejusri

There is no diffrence between int* x and int *x.
but difference will come into picture when you use:

Case 1:
int* x,y,z;

and

Case2:
int *x,y,z;

in first case x,y and z are integer pointer, where as
un second case only x is integer pointer rest y and z is
integer. So its always a good practice not to put multiple
variable in single line.

Is This Answer Correct ?    4 Yes 23 No

Is there any difference between dlearations int* x and int *x? If so tell me the difference?..

Answer / sriram

yes. there is a difference.
Exactly to say, the second form is the integer pointer, but
the first form will produce an run time error.

Is This Answer Correct ?    0 Yes 36 No

Post New Answer

More C++ General Interview Questions

What compiler was used?

6 Answers   Intel,


Is it possible to pass an object of the same class in place of object reference to the copy constructor?

0 Answers  


What is meant by the term name mangling in c++?

0 Answers  


Can I learn c++ as my first language?

0 Answers  


What are the advantages of using const reference arguments in a function?

0 Answers  






What is prototype in c++ with example?

0 Answers  


Describe delete operator?

0 Answers  


what is data encapsulation in C++?

0 Answers  


What is & in c++ function?

0 Answers  


Explain Text Manipulation Routines?

0 Answers  


how to swap two numbers with out using temp variable

12 Answers   Global eProcure, TCS,


What is the difference between C and CPP?

0 Answers   iNautix,


Categories