The C++ expression evaluator accepts almost all C++ expressions, with some restrictions and some additions. This section describes these special considerations.
The debugger can access all class members regardless of access control. You can examine any member of a class object including base classes and embedded member objects.
If a debugger expression refers to an ambiguous member name, you must use the class name to qualify it. For example, if CObject
is an instance of CClass
, which inherits member functions named expense
from both AClass
and BClass
, CObject.expense
is ambiguous. You can resolve the ambiguity like this:
CObject.BClass::expense
To resolve ambiguities, the expression evaluator applies normal dominance rules regarding member names.
When you use the debugger to display a class object that has virtual base classes, the members of the virtual base class are displayed for each inheritance path, even though only one instance of those members is stored. You can access members of an object through a pointer to the object, and you can call virtual functions through a pointer.
For example, assume the class CEmployee
defines a virtual function computePay
, which is redefined in a class that inherits from CEmployee
. You can call computePay
through a pointer to CEmployee
and have the proper function executed:
empPtr->computePay()
You can cast a pointer to a derived class object into a pointer to a base class object. The reverse cast is not permitted.
You cannot call a constructor or destructor for an object, either explicitly or implicitly, using an expression that calls for construction of a temporary object. For example, the following expression explicitly calls a constructor and results in an error message:
Date( 2, 3, 1985 )
You cannot call a conversion function if the destination of the conversion is a class. Such a conversion involves the construction of an object. For example, if myFraction
is an instance of CFraction
, which defines the conversion function operator FixedPoint
, the following expression results in an error:
(FixedPoint)myFraction
However, you can call a conversion function if the destination of the conversion is a built-in type. If CFraction
defines a conversion function operator
float
, the following expression is legal in the debugger:
(float)myFraction
You can call functions that return an object or declare local objects.
You cannot call the new or delete operators. This expression does not work in the debugger:
new Date(2,3,1985)
A debugger expression can call overloaded functions if an exact match exists or if a match does not require a conversion involving object construction. For example, if the calc
function takes a CFraction
object as a parameter, and the CFraction
class defines a single-argument constructor that accepts an integer, the following expression results in an error:
calc( 23 )
Even though a legal conversion exists to convert the integer into the CFraction
object calc
expects, such a conversion involves the creation of an object and is not supported.