Professional Documents
Culture Documents
Basics of C++
Basics of C++
=========
C++ basics OOPs
=============================
It is necessary to understand some of the concepts used extensively
in object-oriented programming. These include:
=> Objects
=> Classes
=> Data abstraction and encapsulation
=> Inheritance
=> Polymorphism
=> Dynamic binding
=> Message passing
{
Float number1, number2,sum, average;
Cin >> number1; // Read Numbers
Cin >> number2; // from keyboard
Sum = number1 + number2;
Average = sum/2;
Cout << Sum = << sum << \n ;
Cout << Average = << average << \n ;
Return 0;
}
Note:
extraction operator : >>
insertion operator : <<
Call by Value
-------------int main(){
Call by Reference
---------------------int main()
{
void swap (int &, int &); //function prototype
.......
........
swap(num1,num2); //function call
}
void swap (int & a, int & b)
{
int temp=a;
a=b;
b=temp;
}
INLINE FUNCTIONS
---------------Eg:
inline void min (int x, int y)
cout<< (x < Y? x : y);
}
Ex: C
Class student
{
private:
char reg_no[10];
char name[30];
int age;
char address[25];
public :
void init_data()
{
- - - - - //body of function
- - - - }
void display_data(){}
};
Inside main
-------------student ob; //class variable (object) created
- - - - - - - - -