














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of object-oriented programming (oop) concepts, focusing on classes and member access. It explains how classes are used to define new types, and the benefits of abstraction. The document also covers the syntax for defining a new user-defined type, accessing members, and the use of access specifiers in c++.
Typology: Slides
1 / 22
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; };