Interview Question

Software Engineer Interview

pointers in c++

Answer

Interview Answer

1 Answer

0

I mean this is a simple question.

int* pi; // pointer to a memory segment where is an integer
int* pd; // pointer to a memory segment where is a double
sizeof(pi) == sizeof(pd) == sizeof(pAnything) == 4; // it is alway true on the 32 bit system (4*8 = 32)
A pointer does not need initialise:
int* pi; // correct expression.
On the other hand a reference have to been initialised by another variable:
int iVariable = 10;
int& ri = iVariable;
int& ri2; // compilation error

Bencze Zoli on May 5, 2012

Add Answers or Comments

To comment on this Question, Sign In with Facebook or Sign Up