Tip Bank

DevX - Software Development Resource

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

DevX - Software Development Resource

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

DevX - Software Development Resource

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

DevX - Software Development Resource

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 &

DevX - Software Development Resource

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

DevX - Software Development Resource

Using self-defined libraries

Question: I am using Borland Turbo C++ 3.1 and I can’t figureout how to use my self-defined libraries. I’ve used”#include” but I get an error every time I try touse

DevX - Software Development Resource

Inheritance and parameter pushing

Question: Why do I need private inheritance in C++?Is it true that (in C++) function parameters are pushed onto the stack from right to left? If so, why? Answer: Use

DevX - Software Development Resource

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

DevX - Software Development Resource

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