C ++ overview-1 Introduction

Source: Internet
Author: User
I. C and C ++

 

  • C history:

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.

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.