














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















class ClassName
{
… DataType MemberVariable; ReturnType MemberFunction(); …
};
Syntax
Syntax
**class Student { int rollNo; char *name; float CGPA; char address; … void setName(char newName); void setRollNo(int newRollNo); … };
Member variables Member Functions
Student aStudent;
aStudent.rollNo = 514;
aStudent.rollNo = -514; //Error
class Student{ int rollNo; void setRollNo(int aNo); };
Student aStudent; aStudent.rollNo;
Error
*class Student{ private: char * name; int rollNo; public: void setName(char ); void setRollNo(int); ... };
Cannot be accessed outside class
Can be accessed outside class
class Student
{
char * name; int RollNo;
};
class Student { private: char * name; int RollNo; };