Abraxas/Meyers: Effective C++  Home  Table of Contents

Module - m12.html

ABRAXAS SOFTWARE - CodeCheck Meyers: Effective C++ Test-Suite

Meyers: Effective C++ Test Suite for Module - m12.cpp

// Item 12: Copy all parts of an object. 57

class Widget {
public:
	Widget();
	~Widget();
 Widget& operator=( const Widget&  ) ;
private:
	int *Wmember1;
	int *Wmember2;
};
Widget& Widget::operator=( const Widget& rhs ) 



Function Name: operator=()

 {	
	Wmember1 = rhs.Wmember1; 	// bad,  Wmember2 not used, rule 12
	 return *this;		
 }
Widget& Widget::operator=( const Widget& rhs )



Function Name: operator=()

 {	
	Wmember1 = rhs.Wmember1;	// good
	Wmember2 = rhs.Wmember2;
	 return *this;		
 }

Abraxas/Meyers: Effective C++  Home  Table of Contents

ABRAXAS SOFTWARE - CodeCheck Meyers: Effective C++ Test-Suite