














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!















►
►
►
►
►
Structures Classes
►
►
Student in student management system Circle in a drawing software
Defining a New User Defined Type
Syntax
Syntax
class
Student
{
int
rollNo;
char
*name;
float
CGPA;
char
*address;
…
void
setName(char
*newName);
void
setRollNo(int
newRollNo);
… };
Member variables
Member Functions
►
►
dot operator (.) to access via the variable name arrow operator (->) to access via a pointer toan object
►
class Student{
int rollNo;void setRollNo(intaNo); };
Student aStudent;aStudent.rollNo;
Error
►
‘public’ is used to tell that member can beaccessed whenever you have access to theobject ‘private’ is used to tell that member can only beaccessed from a member function ‘protected’ to be discussed when we coverinheritance
class Student{private:
char * name;int rollNo; public:
void setName(char *);void setRollNo(int); ...};
Cannot be accessed outside class
Can beaccessedoutside class
►
class Student{
char * name;int RollNo; };
class Student{ private:
char * name;int RollNo; };