Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by sciSpider (sch jbop) (X_X)@==(Q_Q)@

...

Code Block
bgColor#FFcccc
class Body; // incomplete class declaration

class Handle {
  public:
    Handle();
    ~Handle() { delete impl_; } // deletion of pointer to incomplete class
    // ...
  private:
    Body *impl_;
};

...

Code Block
bgColor#ccccff
class Body {
    // ...
};

Handle::~Handle() { delete impl_; } // correct.

...

Code Block
bgColor#ccccff
class Handle {
  public:
    Handle();
    ~Handle() {} // correct.
    // ...
  private:
    std::tr1::shared_ptr<Body> impl_;
};

...

Code Block
bgColor#FFcccc
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
bgColor#FFcccc
class D : public SomeClass, public B {
    // ...
};

B *getMeSomeSortOfB() { return new D; }

...