...
Code Block | ||
---|---|---|
| ||
class Body; // incomplete class declaration
class Handle {
public:
Handle();
~Handle() { delete impl_; } // deletion of pointer to incomplete class
// ...
private:
Body *impl_;
};
|
...
Code Block | ||
---|---|---|
| ||
class Body {
// ...
};
Handle::~Handle() { delete impl_; } // correct.
|
...
Code Block | ||
---|---|---|
| ||
class Handle {
public:
Handle();
~Handle() {} // correct.
// ...
private:
std::tr1::shared_ptr<Body> impl_;
};
|
...
Code Block | ||
---|---|---|
| ||
class B { // ... }; B *getMeSomeSortOfB(); // ... class D; // incomplete declaration // ... B *bp = getMeSomeSortOfB(); D *dp = (D *)bp; // old-stlye cast: legal, but inadvisable dp = reinterpret_cast<D *>(bp); // new-style cast: legal, but inadvisable |
...
Code Block | ||
---|---|---|
| ||
class D : public SomeClass, public B {
// ...
};
B *getMeSomeSortOfB() { return new D; }
|
...