devxlogo

October 25, 1999

Exception in Destructor

Question: If an exception is thrown in a destructor will the data objects in the class be destructed properly? Answer: Throwing an exception from a destructor is a bad idea

string.h

Question: I am a beginner with C++ programming. I was doing fine until I came to the string data type. Here is my problem: #include #include This gives me errors.

Strong Types

Question: How do you make the compiler generate an error when a variable is set to a value outide the range of the constrained type? For example; strong x; //strong

Introspection of classes

Question: In Java using the java.lang.reflect classes, one can find out the name, class, and methods of an object simply by having a reference to that object. Is there a

Calculating interest without floating types

Question: How can you caluculate interest using only integers and no double or floats? Answer: This question can be of interest for anyone who is confined to ineteger arithmetic. Many

Passing a unction as an argument

Question: How do I pass a function as a parameter? Answer: First, let’s distinguish between a parameter and an argument. The parameter is the type of the object passed. An

C++ objects

Question: How can I declare a constant object that is actually constant? Answer: Here’s an example: const Date d; //create a const Date object Note that you can only invoke

anonymous unions

Question: I’m trying to find information regarding anonymous unions in C++. I hear that in C++, one is able to declare a union such as: union example{ int a; int