Beruflich Dokumente
Kultur Dokumente
1
Object Oriented Programming By Amruta Vidwat
Overview
Functions in C++
Specifying a class
Declaring objects
Accessing class members
Member function specification
Making outside member function inline
Syntax:
Type function-name (argument list);
Num in main and num in change: they have different addresses, which means that
they are not the same variable.
Num in main is unaffected.
class class_name
{
private:
variable declaration;
function declaration;
public:
variable declaration;
function declaration;
};
Certified Course in Object Oriented Programming 12
Access to members
Private members: can be accessed only from within the class.
Protected members: can be accessed by own class and its
derived classes.
Public members: can be accessed from outside the class also.
book b1;
Characteristics:
It is individual.
It points to physical or logical thing.
Its scope is limited to the block in which it is defined.
int main()
{
book one; // Object declaration
one.output_val(); // Call to public member function
return 0;
}
void display()
{
cout<<"\n Age\tName\tR.No.\tClass";
cout<<"\n"<<age<<"\t"<<name<<"\t"<<rol<<"\t"<<clas;
}
};
float FloatData()
{
cout << "\nEnter data: ";
cin >> data2;
return data2;
}
};
int main()
{
book one; // Object declaration
one.output_val();
return 0;
}
int main()
{
book one; // Object declaration
one.output_val();
return 0;
}