+ Post New Thread
Results 1 to 2 of 2
  1. #1
    Full Member level 4
    Points: 3,250, Level: 13

    Join Date
    Nov 2006
    Location
    Guwahati, India
    Posts
    235
    Helped
    1 / 1
    Points
    3,250
    Level
    13

    How to get the output of this c++ code?

    Dear all,

    I've an incomplete c++ code give as below:
    Code C++ - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    
    #include <iostream>
    using namespace std;
     class sample {
    int x;
    public:
                 sample():x(0) {}
                 sample(int x):x(x) {}
                 sample(const sample &obj): x(obj.x) {}
     
                 void display() {cout << x << "  ";}
                            };
     
                 int main() {
                 int val;
                 cin >> val;
                      
                 ...................... ;        //Default construcor
                 ...................... ;       //Non-default Constructor 
                 ...................... ;       //Copy-Constructor
                                                     
                objA.display();
                objB.display();
                objC.display();
                return 0;
                }

    1) Case 1: When input = 25 , Output = 0 , 25 , 25
    2) Case 2: When input = 16 , Output = 0, 16,16


    I'm not getting the logic to complete the same. Can someone help me in this?

    Regards

    •   AltAdvertisement

        
       

  2. #2
    Member level 2
    Points: 569, Level: 5
    ArakelTheDragon's Avatar
    Join Date
    Jul 2017
    Location
    If you like the post, please press "Like".
    Posts
    48
    Helped
    8 / 8
    Points
    569
    Level
    5

    Re: How to get the output of this c++ code?

    If you liked the post, please press "Give points" and "Helped me".



--[[ ]]--