Theoretical exercises
[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