The Home of Technology

Select your Language

| | | | | | | Blogger Tips And Tricks|Latest Tips For BloggersFree BacklinksBlogger Tips And Tricks | | | | | | | | | | | | | | | | | | | | | | | | | |

Friday, October 9, 2015

Passing Function to Objects

No comments :
Here I am going to Introduce you with the Objects in c++
Here is the link of tutorial video

The code is giver below....
#include<iostream>
using namespace std;

class myclass
{
    int i;
public:
    myclass(int a) {i=a;}
    int get_i() {return i;}
    int sqr_it() {return i*i;}
};

int sqr_i(myclass o)
{
    return o.get_i()*o.get_i();
}

int main()
{
    myclass a(10);
    cout<<sqr_i(a)<<endl;
    cout<<a.sqr_it();
}

No comments :

Post a Comment