devxlogo

Tip Bank

MTS and Passing Direct Reference

MTS objects clients should never have access to unsafe references. A client application should never be passed a direct reference to an MTS object. Once such a reference is passed

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

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.

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

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

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

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