TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Thursday 4 June 2020

Returning Object In C++ | Returning Object With Example | Returning Object With Syntax | Returning Object Hindi

Returning Object


A function can also return objects either by value or by reference. When an object is returned by value from a function, a temporary object is created within the function, which holds the return value. This value is further assigned to another object in the calling function.


image of Returning Object In C++

Fig:Returning Object In C++ 


Synatx:

classname functionname(argument list)

{

function of body;

}


Program:

#include<iostream.h>

#include<conio.h>

class MCA

{

int a,b;

public:

void getdata(int, int);

void disp();

MCA sum(MCA,MCA);

};

void MCA::getdata(int x,int y)

{

a=x;

 b=y;

}

void MCA::disp()

{

cout<<a<<b;

}

MCA sum(MCA u,MCA v)

{

int z;

z=v.a + u.b;

z=v.b + u.a;

}

void main()

{

MCA s1,s2,s3;

s1.getdata(100,2);

s2.getdata(200,5);

s3.sum(s1,s2);

cout<<s1.disp();

cout<<s2.disp();

cout<<s3.disp();

getch();

}

 


No comments:

Post a Comment