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; }
};
Posted in Computer Science, Information Technology, Object Oriented Programming, Object Oriented Programming |
