Home C++ Introduction Decisions Loops Input/Output Functions Stack and Heap References Arrays Searching and Sorting Recursion Pointers Character and Strings Structures Classes Inheritance Exceptions Templatess STL Modern C++ Misc Books ----

Classes


Contents

If we write the class body methods in the class declaration then those functions are automatically inline without us explicitly using the work "inline" .
File: inline.cpp
#include <iostream>
using namespace std ;

class Demo
{
    public:
     int x1 ;
     int x2 ;
    Demo(int x1P = 4, int x2P = 5)
    {
        x1 = x1P  ;
        x2 = x2P ;
        cout << "Inside the construtor method." <<
        endl ;
     }
     void print()
     {
         x1 = x1P  ;
         x2 = x2P ;
         cout << "Inside the constructor method." << endl ;
      }
};

int main()
{
    Demo demo1Obj( 4 , 6 )   ;
    Demo demo2Obj   ;
    demo2Obj.print() ;
}

Friend

Const functions

OO

Smart Pointer