Week 6 computer task project 1-(2)

Source: Internet
Author: User
01/* 02 .*ProgramCopyright and version description section 03. * copyright (c) 2013, Yantai University Computer college student 04. * All rightsreserved. 05. * file name: C. CPP 06. * Author: Zhao guanzhe 07. * Completion Date: April 8, April 4, 2013. * version: V1.0 09. * input Description: 10. * Problem description: 11. */# include <iostream> # include <stdlib. h> using namespace STD; Class C {PRIVATE: int X; public: C (int x) {This-> X = x;} int getx () {return x ;}}; int main () {C (5); cout <C. getx (); Return 0 ;}

Running result:

Summary:

Compared to the two modification methods. It is better to add the first const, because after adding the const, the information is shared, but cannot be modified, so that the program can be normally carried out, avoid unnecessary mistakes.

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.