954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

difference between a class declaration and a class definition

what is the difference between a class declaration and a class definition ?
Is it that a class which contains the prototypes of member functions is a class declaration?
Is it that a class with member functions defined within the class , is a class definition ?

kneiel
Newbie Poster
19 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

A class declaration is anything, essentially, that tells the compiler a name is for a class. For example;

class  ClassName;

is known as a "forward declaration".

A class definition is a type of declaration that provides enough information that a compiler can create instances of the class, compute sizeof() for the class, call member functions, and access data members of the class.

A class with "prototypes of member functions" is one type of class definition.

A class "with member functions defined in the class" is another type of class definition - the only difference is that it is a class definition with inline definitions of member functions.

grumpier
Posting Whiz in Training
211 posts since Aug 2008
Reputation Points: 193
Solved Threads: 32
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You