POJ C + + Programming programming Jobs-class and Object programming questions # #

Source: Internet
Author: User

Programming Question # #

Source: POJ (Coursera statement: The exercises completed on POJ will not count against the final results of Coursera. )

Note: Total time limit: 1000ms memory limit: 65536kB

Describe

The output of the following program is:

10

Please complement the member functions of the sample class. Member variables cannot be added.

#include <iostream>using namespace Std;class sample{public:    int v;    sample (int n): V (n) {}//to supplement your code here};int main () {    Sample a (5);    Sample B = A;    cout << B.V;    return 0;}
Input

No

Output

10

Sample input
No
Sample output
10
1#include <iostream>2 using namespacestd;3 classsample{4  Public:5     intv;6Sample (intN): V (n) {}7Sample (Sample &a) {8v =2*A.V;9     }Ten }; One intMain () { ASample A (5); -Sample B =A; -cout <<B.V; the     return 0; -}

POJ C + + Programming programming Jobs-class and Object programming questions # #

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.