"C + +" C + + Learning Journey (1): New acquaintance, C's upgraded version

Source: Internet
Author: User

The school will start next semester, but the witty I decided to study by myself. Borrowed two C + + books from the library, one is Bjarne Stroustrup's C + + programming language, one is the Tian Shouxia Editor-in-chief of Tsinghua University Press, "C + + Advanced program design." I would like to self-study the former, a freshman no basis, simply do not understand, but give up, choose a lot of thin, it is possible that the latter of our textbooks. Well, that's it. Officially began to learn.

I have C language Foundation, last semester learned the same series of book "C Programming Fast Advanced University Course", also is a cursory understanding of C language. C + + is the development and supplement of C language, is "C with Class". C + + has improved the shortcomings of C. Support object-oriented programming, while preserving the simplicity and efficiency of C while improving.

Here is a summary of this time self-taught my little harvest it:

I. Process-oriented and object-oriented

Process-oriented program design is a process-centric programming idea, which is to seek refinement from the top down, it has many shortcomings: low development efficiency, poor reusability of programs, high maintenance costs, and inability to adapt to the rapid expansion and diversification of information. C language is process oriented.

Object-oriented programming encapsulates the data and the method of processing the data in an object to deal with it as a whole. C + + As an object-oriented program design has encapsulation and data hiding, inheritance and derivation, polymorphism and other major features.

Data units used by computer to represent and store data

① bit (bit), précis-writers B, is the smallest unit of data that is stored in the computer. A bit can only represent a switch volume, such as 1 for the switch closure, 0 for disconnection.

② byte (byte), précis-writers B. 1b=8b. Bytes are important units of data, and the size of the computer's storage capacity is measured in bytes:

1kb=210b=1024b 1mb=210kb 1GB=210MB

③ Word (word). Word length is the number of actual bits that a computer can handle at a time, which determines the speed of computer data processing, and thus is an important indicator of computer performance.

Three, different from the C language syntax

Let's look at a simple sample applet:

 #include <iostream> 
using Std; int Main () { string greeting = " hello world! " char ch; CIN >>CH; cout << hello World " <<ENDL; cout <<greeting<<ENDL; cout <<CH;}

  1. <iostream> The file contains the definition of the input and output stream.

2, using namespace std; Tell the compiler that all the names used in this program belong to the namespace Std. In the process of writing large programs, multiple programs work together, so they are likely to have the same name for different things, and the namespace mechanism can effectively avoid this conflict. (This problem is not understood now, understand and then to solve)

3, there is a string variable yo, string, this is the C language does not.

4, the new input and output mode-input and output stream. cout output, cin input. Use See program code.

5, more a bool (Boolean type), True or False ~ ~

6, say a kind of something similar to # define: Const, different is the const to write constant type, such as:

const int Max = 100;const float PI = 3.14159;

  Many other things are the same as the C language, it is not said.

Well, it's the first time you've written so much.

"C + +" C + + Learning Journey (1): New acquaintance, C's upgraded version

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.