devxlogo

Tip Bank

What to do with overload arguments

Question: Which arguments do you receive when you overload . and -> , and what do you do with the arguments? I know that for overloading [] you receive the

Compilers: Which is best?

Question: Which model of C/C++ compiler offers the best value for a beginning programmer?(It must be ANSI C compatible.) Answer: The GNU G++ compiler. It’s free, ANSI C compatible and

Inheritance design

Question: Suppose I’ve got the following class hierarchies:Surface_PlotContourSurface_Plot, child of Surface_PlotSurface_DataGridSurface_Data, child of Surface_DataSurface_Plot contains a Surface_Data object, ContourSurface_Plot contains a GridSurface_Data object.What is the most elegant way to arrange

File handles/pointers

Question: In C, I use the FILE *filename. As a beginning C++ programmer, I open streams for reading and writing inside the main() function, but when I try to work

Memory allocation at compile time

Question: Consider the following piece of code:#include /* C++ String class */static String s(“hello”);main() { // … your code s += ” world”; // …}Question: String class uses the new

Possible to read integers as integers?

Question: Is it possible to read integers from a file as integers, or must I read them as strings and then convert them to integers? Answer: In C++ the streams

Reference Counted Implementation

Question: For a reference counted implementation, how is the operator+= member function coded? The function receives (const String & rhs) and returns String &. The returned String &