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

Object Assignment In C++ | Object Assignment Example | Object Assignment Syntax

Object Assignment


If want one object to second object we have to assign then we have to use assignment operator.

If want one object to second object assign the value then we have to create two object.

If first object value is a1 then second object value is a2 then the value of  a1 and the value of a2  will assign in object.


image of Object Assignment In C++

Fig: Object Assignment In C++

Example:

a2=a1;


Program:

#include<iostream.h>

#include<conio.h>

class MCA

{

private:

int  x,y;

public :

void getdata();

void putdata();

};

void MCA:: getdata()

{

cout<<”input two number”;

cin>>x>>y;

}

void MCA::putdata()

{

cout<<”x=”<<x;

cin>>x>>y;

}

void main()

{

MCA a1,a2;

a1.getdata();

a2=a1; //object assignment

a1.putdata();

cout<<”after data /n”;

a2.putdata();

getch();

}


Output:

Input two number 20

30

x=20

y=30

after data

x=20

y=30


No comments:

Post a Comment