C++ Revisited
I have learnd C++ before and I know C++.But I cannot write any piece of C++ program without compiler's complaints. Itis the time to re-visit it.
I take it as a new language though I knowsomehting about it, though I am quite familiar with C and Java. It is a newlanguage.
Here is what I get when learning C++ andthey are worth referencing, I think, when learning C++.
int &a = 4; // Error
Pass-by-value would invoke copy constructorand assignment operator which is costly for objects. For built-in types, copyand assign would cost too much and most times, people like passing literalconstants which would cause error if argument is pass-by-value.
void Grade::setScore( const float &sc); math.setScore( 89.5f ); // Error setScoreuse pass-by-reference.
Return reference might cause fatal errors,you might return a reference to local variables.
Returning pointers might cause memory leak.
Return objects is much safer thoughinvoking copy constructor.