[Exceptional C++ Style] Fw: const data - was Item 17

Balog Pal pasa at lib.hu
Mon Dec 20 15:46:51 EST 2004


> Would it be ok to show me 17-a and 17-b? I won't be able to get a copy 
> of the book for a while now...

Most of the item stuff you fing in gotw#70  http://www.gotw.ca/gotw/070.htm

// Example 2(a): Nonprivate data (evil)
//
class X
{
  // ...
public:
  T1 t1_;
protected:
  T2 t2_;
};



// Example 2(b): Encapsulated data (good)
//
class X
{
  // ...
public:
  T1& UseT1() { return t1_; }
protected:
  T2& UseT2() { return t2_; }
private:
  T1 t1_;
  T2 t2_;
};






More information about the Effective-cpp mailing list