C ++ learning and learning

Source: Internet
Author: User

C ++ learning and learning

Machine language = process-oriented = object-oriented.

Overload: The function name is the same, and the parameters are different (type, number );

Overload is not an object-oriented feature, but a solution to simplify programming interoperability;

Note: be cautious about function (method) overloading, and pay attention to operator overloading and overwriting;

Complex data types:

Array, pointer, structure, Class

Array: stores values of the same type in the same variable name. It still needs to be declared as a specific type: float, char, int ----

Note: in C language, we generally store strings in a character array, but in C ++, we generally use a string object.

Alignment: The 32-bit system is 4 bytes, And the 64-bit system is 8 bytes. Memory alignment and file alignment.

The pointer is the type * pointerName variable used to store the address. Therefore, you can place the address in the pointer variable.

Asterisk usage: the first is used to create a pointer, and the second is to unreference the pointer.

C ++ supports the void * vPpinter without a type pointer. You must first convert it to an appropriate data type before resolving the reference.

Pointers and arrays:

The array name is the first address of the array.

Thoughts:

# Include <iostream> using namespace std; int main () {const unsigned short ITEM = 5; int intArray [ITEM] = {1, 2, 3, 4, 5 }; char charArray [ITEM] = {'A', 's', 'D', 'F', 'G'}; int * intPtr = intArray; char * charPtr = charArray; cout <"integer" <endl; for (int I = 0; I <ITEM; I ++) {cout <* intPtr <"at" <reinterpret_cast <unsigned long> (intPtr) <endl; intPtr ++ ;}for (int I = 0; I <ITEM; I ++) {cout <* intPtr <"at" <intPtr <endl; intPtr ++ ;} cout <"optimized" <endl; for (int I = 0; I <ITEM; I ++) {cout <* charPtr <"at" <reinterpret_cast <unsigned long> (charPtr) <endl; charPtr ++ ;}for (int I = 0; I <ITEM; I ++) {cout <* charPtr <"at" <charPtr <endl; charPtr ++;} return 0 ;}

There is a difference between the output result of character and integer: The Impact of reinterpret_cast <unsigned long> ()

?

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.