devxlogo

July 18, 1997

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

Friend class and function

Question: I need to know what the class or function called “friend” is. My teacher explained it in class, but I don’t quite understand how to call it and declare

Storing strings in a char array

Question: This is actually a simpler form of the real problem I am dealing with. I have a array of char like so:char name[20];Then, I try to put a string

VC++ 5.0 and STL predicates

Question: How can I provide my own predicate for the list::sort method in Visual C++ 5.0? The method appears to require that any function object passed must be derived from

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 &

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

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