Professional Documents
Culture Documents
by default all class member are private if we are not use access specifier
1. private
2. protected
3. public
access specifier specify the accessibility of the members
private means we can access only within a class ]protected is same as private till
inheritance
class A
{
public:
int a; = a is public
protected
int b;
= b and c both are protected
in c;
}
class A
{
public:
int a; = a and b both are public
int b;
private = c is private
in c;
}
in c++ we always use semicolon at the end of class after the class to teminate
class
in c we use semicolon at the structure
in java and c# not use semicolon at the end of class
procedural
oops is set of rules or concepts or approach to solve the problems
}
#include<iostream>
using namespace std;
class MPGI
{
//data
public:
int a,b,c;
//methods
public: //Access specifier
void input();
void process();
void output();
};
void MPGI:: input()
{
cout<<"Enter two numbers: ";
cin>>a>>b; //input
}
void MPGI:: process()
{
c=a+b; //process
}
void MPGI:: output()
{
cout<<"Sum= "<<c;
}
int main()
{
MPGI obj;
obj.input();
obj.process();
obj.output();
return 0;
}
normal function
inline function
you can not make every function as inline because inline is the keyword which
request the compiler (it depends the rules follow by the compiler)
#include<iostream>
using namespace std;
if any member method is defined inside the class then it by default inline not need
to use keyword inline
good coder do small function that is one r two line that keeps inside the class and
the function which has line of
code more than one or two then keep it outside of the class
INLINE FUNCTION==
Interview question
what is the differece between inline function and macro function?