I. C and C ++
Born in, the author is Dennis Ritchie from Bell's laboratory.
In, the C language standard ansi c was introduced.
- Main features of c language:
1. You can directly access the memory, perform bit operations, and develop system software.
2. The generated target code is highly efficient.
- C ++: in 1980, Bell's Stroustrup started to improve C. In 1983, it was officially named C ++. In 1994, the ansi c ++ standard was published.
- C ++ features:
1. Based on C, it fully includes all the features and advantages of C.
2. The biggest difference from C is that C ++ fully supports OO. C ++ can be used as a process-oriented language, it can also be used as an object-oriented language. C ++ is comprehensive.
Ii. Programming
- Structured Program Design: main features: functional decomposition, gradual refinement.
- OO program design: main features: encapsulation and data hiding, inheritance and reuse, polymorphism.
3. C ++ Program Development Process
1. Write the source file with the suffix. c or. cpp.
2. compile it into the. obj target file. These files are already machine code, but cannot be run.
3. Connect the. obj target file and the. lib library file to generate executable programs on the computer.
4. C ++ program development example
1: //*************************************
2: //** eg1.1
3: //*******************************
4: # include <iostream. h> // The file contains the compilation and preprocessing commands.
5: #include <math.h> //
6:
7: double max (double x, double y); // function declaration. A function must be declared before it can be called.
8:
9: void main()
10: {
11: double a, B, c; // variable declaration, allocating memory space for the variable
12: cout<<"input two numbers.\n"<<endl;
13: cin>>a>>b;
14:
15: c=max(a,b);
16:
17: cout<<"the squart of maximum is "<<sqrt(c);
18: }
19:
20: // The following is the function definition, that is, the specific implementation of the function.
21: double max(double x,double y)
22: {
23: if(x>y)
24: return x;
25: return y;
26: }
A c ++ program consists of three parts: Comments, compiled pre-processing commands, and program subjects.