November 1999
Intermediate to advanced
336 pages
6h 29m
English
In an ideal world, there would never be a chapter dedicated to the performance implications of constructors and destructors. In that ideal world, constructors and destructors would have no overhead. They would perform only mandatory initialization and cleanup, and the average compiler would inline them. C code such as
{
struct X x1;
init(&x1);
...
cleanup(&x1);
}
would be accomplished in C++ by:
{
X x1;
...
}
and the cost would be identical. That's the theory. Down here in the trenches of software development, the reality is a little different. We often encounter inheritance and composition implementations that are too flexible and too generic for the problem domain. They may perform computations that ...
Read now
Unlock full access