The Home of Technology

Select your Language

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

Friday, October 9, 2015

Returning Objects from Function

1 comment :
 click here for video Tutorial

#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;

class myclass
{
    char s[80];
public:
    void set(char *str) { strcpy(s,str);}
    void show() {cout<<s<<endl;}
};

myclass input()
{
    char s[80];
    cin>>s;
    myclass ob;
    ob.set(s);
    return ob;
}

int main()
{
    myclass o;
    o=input();
    o.show();

    return 0;
}

1 comment :