






























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
Main topics in this course are object-orientation, objects and classes, overloading, inheritance, polymorphism, generic programming, exception handling, introduction to design patterns. This lecture includes: Member, Function, Orient, Program, Object, Concept, Definition, Data, Member, Access
Typology: Slides
1 / 38
This page cannot be seen from the preview
Don't miss anything!































►
Class^
Concept Definition
►
Data members ►
Member Functions ►
Access specifier
►
Define member function inside the classdefinition
►
Define member function outside the classdefinition^
But they must be declared inside class definition
class
Student{
int
rollNo;
public:
void
setRollNo(int
aRollNo){
rollNo
aRollNo;
class
ClassName
{
… public:ReturnType
FunctionName
();
};ReturnType
ClassName
::
FunctionName
()
{
… }
Scope resolution
►
Instead of calling an inline function compilerreplaces the code at the function call point ►
Keyword ‘inline’ is used to request compilerto make a function inline ►
It is a request and not a command
inline
int
Area(int
len,
int
hi)
return
len
hi;
} int
main()
cout
Area(10,20);
class
Student{
int
rollNo;
public:
void
setRollNo(int
aRollNo){
… rollNo
aRollNo;
class
Student{
… public:inline
void
setRollNo(int
aRollNo);
}; void
Student::setRollNo(int
aRollNo){
… rollNo
=
aRollNo;
}
class
Student{
… public:inline
void
setRollNo(int
aRollNo);
};inline
void
Student::setRollNo(int
aRollNo){
… rollNo
=
aRollNo;
}
►
Constructor is a special function havingsame name as the class name ►
Constructor does not have return type ►
Constructors are commonly public members
class
Student{
public:
Student(){
rollNo