"C + + GUI QT4 Programming (second Edition)"--reading experience

Source: Internet
Author: User
Tags function prototype

the Appendix D "

Getting Started with C + +

You can implement multiple classes in the same . cpp file, or you can spread the implementation of one class into multiple . cpp files

650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M00/5B/42/wKioL1UD-1OycQeZAADzjdjiyg0642.jpg " Title= "C + + compilation process" alt= "wkiol1ud-1oycqezaadzjdjiyg0642.jpg"/>

int main (int argc, char *argv[])//argc:argument count,argv:argument value

Argv[0] The name of the depository program, argv[1],argv[2],... , Argv[argc-1] store command line arguments

Header file: Place the function prototype in a separate file, including it in all the compilation units that need to call the function.

Form:

#ifndef xxx_h #define XXX_H ... #ENDIF

#include <XXX>: angle brackets indicate that the header file XXX is located in the system's standard location

#include " XXX " : Find header file in current directory XXX

The header file is not a compilation unit, does not produce a target file, and contains only declarations that allow different compilation units to relate to each other.

Executable programs connect to many libraries

Static libraries: can be placed directly into the executable program (just like the target file)

Dynamic library: (Shared library /dll) is located in a standard location on the user's machine and is loaded automatically when the application starts

Basic data types

Instances of built-in types are not initialized by default.

Qlonglong,Qchar

the Qdatastream class is used to store platform-independent binary data

Class

Class is divided into three segments: public,protected,private without defined segments, default to Private Segment

When an inline functioncalls a function declared as an inline function, the compiler simply extends its function body and does not generate the actual function call ==>(faster)

Only very short functions should be implemented as inline functions

C + + does not provide a generic class Object that can be inherited for all classes

Pure virtual function = = "interface"

C + + does not allow the initialization of member variables in class definitions

Class variables, instance variables

Each static member variable must be defined in a . cpp file

Pointer

Heaps (heap)

Stacks (stack)

Cantilever pointer (dangling pointer) "smart" pointer:qpointer<t>

A constant pointer to a class can only be used to invoke a constant member function

"Copy on Write" in Qt (copy onwrite)

Reference

a reference in C + + stores the address of an object, unlike a pointer:

1. Disclaimer: Use "&" insteadof "*";

2. Must be initialized, cannot be re-assigned again after;

3. Direct access to the object associated with the reference;

4. Cannot be empty (null)

Array

std::memcpy () can copy a piece of data in memory

To create a variable-size array:

1. Assigning the array dynamically

2. Using the std::vector<t> class

#include <vector> std::vector<int> Array (n);

3. qvector<t> class using Qt

#include <QVector> qvector<int> Array (n);

Template classes: classes that include <> in class names

String

In C + + , the literal of a string isasimple constant character array that ends with an implicit "+" Terminator

QString

Enumeration

Sometimes enumerations are used to declare integer constants, and the name of the enumeration is usually omitted:

enum{Monday = 1; }

In other cases, enumerations are used to express the collection of options, with an enumeration constant that is the value of a power of 2 to represent the individual selections , each of which is oftenreferred to as "flag", and the bitwise operator can be used | "or" |= to combine these tags, you can use the bitwise operator & totest whether a tag is selected.

Type aliases

Type conversions

Static_cast<t> () converts a pointer to a pointer to b , class b must be a class A sub-class

Dynamic_cast<t> () run-time type information (RTTI,runtime type information) validation

Const_cast<t> () add / Remove a const qualifier on a pointer or reference

Reinterpret_cast<t> () converts any type of pointer or reference to any other type

Data type VOID * can store address of any type of instance

Keyword explicit to disable the auto-transform feature

Operator overloading

Value type

Value type, reference type (referencetype)

all types in C + + can be used as reference types

If you want to have a C + + class has a replicable nature, you must ensure that the class has a complex constructor ( copy Constructor ) and an assignment operator. When you define a class, the C + + compiler automatically provides a copy constructor and an assignment operator to perform member-to-member replication.

Global variables and global functions

Not to be continued ....


This article is from the "V-Face" blog, be sure to keep this source http://xuzhen1024.blog.51cto.com/8881317/1620381

"C + + GUI QT4 Programming (second Edition)"--reading experience

Related Article

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.