November 1999
Intermediate to advanced
336 pages
6h 29m
English
Lazy Evaluation is about computations that are not always necessary, depending on execution flow. Useless computations are about those computations that are never necessary. These are entirely pointless computations whose results are never used regardless of execution flow.
A subtle example of a useless computation is the wasted initialization of a member object.
class Student {
public:
Student(char *nm);
...
private:
string name;
};
The Student constructor turns the input character pointer into a string object representing the student's name:
Student::Student(char *nm)
{
name = nm;
...
}
C++ guarantees that all member objects have already been constructed before the body of the Student constructor is executed. In our ...
Read now
Unlock full access