Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

rahul.6sept

Full Member level 5
Joined
Nov 17, 2006
Messages
243
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
Guwahati, India
Activity points
2,889
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
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top