Bloomberg LP Interview Question
Financial Software DevelopersIn addition to GekkoGorden's comment:
If we want to use the following function as MyFn(1);
void MyFn(const int * p);
Compiler will shout.
But, same we can achieve with references:
void MyFn(const int& v);
This function will work for both const or non-const variables or objects.
In such situations we avoid using pointers.
1. use pointers when you know a variable might point to NULL, if your design does not allow for the possibility that the variable is null, you should probably make it a reference variable.
- GekkoGordan January 27, 20112. pointers can be reassigned but references cannot be. a reference, however, always refers to the object with which it is initialized.
- Item 1 : Basics: Pointers Vs References: from Scott Meyers book "More Effective C++"