Search
 
SCRIPT & CODE EXAMPLE
 

CPP

object as a function argument and returning object

//Object as a function argument and returning object **sudipnext**
#include<iostream>
using namespace std;
class display{
    int x, y;
    public:
    display add(display m, display n){
        display temp;
        temp.x = m.x + n. x;
        temp.y = m.y + n.y;
        return temp;
    }
    void getData(){
        cout << "Enter the value of x";
        cin >> x>> y;
    }
    void result(){
        cout << "The ans are for x:- "<< x<< " and for y :- "<< y<<endl;
    }


};
int main(){
    display obj1, obj2, obj3, obj4;
    obj1.getData();
    obj2.getData();
    obj4 = obj4.add(obj1, obj2);
    obj4.result();
    return 0;

}
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to get the last digit of a number 
Cpp :: sort sub vector, sort range of vector c++ 
Cpp :: how to make a goto area in c++ 
Cpp :: Processing a string- CodeChef Solution in CPP 
Cpp :: check if an item is in a vector c++ 
Cpp :: what is the format specifier for dword c++ 
Cpp :: are maps sorted c++ 
Cpp :: c++ cin accept only numbers 
Cpp :: round function in c++ 
Cpp :: how to call subclass override method in c++ 
Cpp :: online c++ compiler 
Cpp :: while loop in c++ 
Cpp :: 18 in 12 hour time 
Cpp :: short hand if else in c++ 
Cpp :: size of set c++ 
Cpp :: sum function in c++ 
Cpp :: how to put string in array c++ 
Cpp :: nazi crosshair c++ 
C :: color text in C 
C :: c distance in the cartesian plane 
C :: how to print something out to the console c 
C :: check if string starts with c 
C :: close file in c 
C :: c static 
C :: write a program in c to check whether the number is armstrong or not 
C :: string compare c 
C :: Futter Square Button 
C :: sequelize count multiple associations 
C :: add char to char array c 
C :: make a function makefile 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =