Inline Member Functions - C++ Class

C++ examples for Class:Member Function

Description

Inline Member Functions

Demo Code

#include <cstdlib> 
#include <iostream> 

using namespace std; 

class point /*  w w w.ja v  a  2 s .c o m*/
{ 
public : 
    point() 
    { 
        x = y = 0; 
    } 

    void SetX(int xValue) 
    { 
        x = xValue; 
    } 

    int GetX(void) 
    { 
        return (x ); 
    } 

    void SetY(int yValue) 
    { 
        y = yValue; 
    } 

    int GetY(void) 
    { 
        return (y ); 
    } 

private: 
    int x , y ; 
}; 

int main(int argc, char *argv []) 
{ 
    point rightHere; 

    rightHere.SetX(10); 
     rightHere.SetY(20); 

    cout << "(x ,y )=(" << rightHere.GetX(); 
    cout << "," << rightHere.GetY() << ")"; 
    cout << endl; 

    rightHere.SetX(20); 
    rightHere.SetY(10); 

    cout << "(x ,y )=(" << rightHere.GetX(); 
    cout << "," << rightHere.GetY() << ")"; 
    cout << endl; 

  
    return (0); 
}

Result


Related Tutorials