Program Practice: C + + Overview

Source: Internet
Author: User

Theoretical exercises
    • What are the essential differences between C + + and language?

[Reference answer]: C + + and C are fundamentally different in that C + + is Object-oriented , and the language is process-oriented .

    • How does the process-oriented program design approach differ from the object-oriented programming approach in treating data and function relationships?

[Reference answer]:

In process-oriented programming , data is only considered a static structure, and it only waits for the function to be called to process it.

In object-oriented programming , the data and functions that legitimately manipulate the data are encapsulated together as a class definition, and the encapsulation provides a mechanism for strict control of data access , so The data is hidden in the package, which exchanges information with the outside world through the interface of the operator.

On-Machine Internship problem
    • Familiar with and master the programming environment of VC + + 2008/dev-c++.
(1) The process of editing a single program.

(2) The process of establishing the project.

    • Create and edit the following individual programs and execute them.
/* File name: abc.cpp*/#include <iostream.h> void Main () {    int x,y,z,max;    cout << "input x y z:";    Cin >> x >> y >> z;    if (x>y)       max=x;    else       max=y;     if (max<z)       max=z;     cout << "max=" << Max << Endl; }

Once the program is compiled, the results of one execution are as follows: Input x y z:2 5 4 max=5

 
 
    • Build a project proj1, which contains the following two files, build and edit this project, and execute.
/* File name: file1.cpp*/#include <iostream.h> extern int max (int,int); void Main () {   int x,y,z,m;   cout << "input x y z:"; Cin >> x >> y >> z;   M=max (x, y);   M=max (m,z);   if (m<z) m=z;   


/* File name: file2.cpp*/int max (int x,int y) {    if (x>y)      return x;    else      return y;}
The results of one execution are as follows: Input x y z:2 5 4 max=5


For more discussion and exchange on program language, please follow this blog and Sina Weibo songzi_tea.



Program Practice: C + + Overview

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.