Sections


Main-Menu

header image

Class Declaration


Class Declaration

Usually functions are public but the data within the class are private. Thus, the data is hidden so that it will be safe from accidental manipulation, whereas functions are public so that they can be accessed from outside the class.

class name                          // class name with keyword ”class”
{
private:                         // access specifier
int data;                   // private data
public:                         // access specifier
void getdat (p)        //  public function
{   data = p;   }
};


Related Articles :



Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Shaadi.com Matrimony - Register for FREE