Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C++
Reference
C/C++ Languages

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual C++ Language Reference
Special Member Functions

C++ defines several kinds of functions that can be declared only as class members — these are called "special member functions." These functions affect the way objects of a given class are created, destroyed, copied, and converted into objects of other types. Another important property of many of these functions is that they can be called implicitly (by the compiler).

The special member functions described in this section are as follows:

The items in the preceding list can be user-defined for each class.

Special member functions obey the same access rules as other member functions. The access rules are described in Member-Access Control. The following table summarizes how member and friend functions behave.

Summary of Function Behavior
Function Type Is Function Inherited from Base Class? Can Function Be Virtual? Can Function Return a Value? Is Function a Member or Friend? Will Compiler Generate Function if User Does Not?

Constructor

No

No

No

Member

Yes

Copy Constructor

No

No

No

Member

Yes

Destructor

No

Yes

No

Member

Yes

Conversion

Yes

Yes

No

Member

No

Assignment (operator=)

No

Yes

Yes

Member

Yes

new

Yes

No

void*

Static member

No

delete

Yes

No

void

Static member

No

Other member functions

Yes

Yes

Yes

Member

No

Friend functions

No

No

Yes

Friend

No

Other Resources

C++ Language Reference

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Special Member Functions      Shrinivas Dudhani   |   Edit   |   Show History

It is good practice to write our own version of special function and not relay on compiler genrated version.

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker