Home | Computer Science
<
Classes and Objects
Defination
Class is a combination of Data member and member fuctions.
Classes and Objects
Syntax of it is
class abc{
private: int a,b;
public: void add{
}
};
Three are three types of Memory Accessor
- Private ( Only Authorised can access )
- Public ( both authorised and unauthorised can access it )
- Protector ( Class and freind functions of class )
Some important information
- Variables are called as Data members
- Functions are called as Member Functions
Program
INPUT
#include <iostream>
#include<conio.h>
class abc{
private:
int a,b;
public:
void add()
{
a=10;
b=20;
b=a+b;
cout<< b;
main() {
abc a1;
a1.add();
getch();
}
OUTPUT