Program Practice Series (vii) C + + Overview

Source: Internet
Author: User

Theoretical exercises
    • What is the essential difference between the C + + and language?

[Answer]: C + + is fundamentally different from C language in that C + + is Object-oriented . and the C 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?

[Answer]:

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

In object-oriented programming . Encapsulates the data and the functions that legitimately manipulate the data as a definition of a class. Other than that. Encapsulation also 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 individual programs below. and run.
/* 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 run are as follows: Input x y z:2 5 4 max=5

 
 
    • Build a project proj1, which includes for example the following two files, creating and editing this project. and run.

/* 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;}
One run result such as the following: input x y z:2 5 4 max=5


For a lot of other discussions and exchanges with program language, please follow this blog and Sina Weibo songzi_tea.



Program Practice Series (vii) C + + Overview

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.