Bloomberg LP Interview Question
Financial Software DevelopersReference: has to be initialized when declared
cannot reseat once refer to an object
cannot do arithmetic operation, int& ref=&a, ref++ will be wrong
cannot be assigned with NULL
cannot take the reference of a reference variable, pointter of pointer is possible
As a general rule,
Use references in function parameters and return types to define attractive interfaces.
Use pointers to implement algorithms and data structures.
1. pointer could be NULL while reference must be alias for some object; pointer can be reassigned to point to other objects, while reference must always be the alias for the same object.
2. struct has no member function? not sure tho
3. new and delete. new calls constructors while malloc does not
In case of C#, Structures and Classes are different because structures are allocated on stack and class objects are allocated on heap. Structures does not support inheritance, as they're implicitly sealed. Furthermore, no member function of a Structure can be virtual, also destructors and finalize methods cannot be written for structures.
2. struct and class are same except that struct has a member as public by default while class has a member as private by default.
- drwolf February 25, 2009