C ++ written examination

Personal finishing, drawing on a network

1 difference, C and C ++, a struct

1), C is a private property and protect non-struct, C ++ are

2), C can not be defined function, C ++ can

3), C added in typedef struct type can be defined as, C ++ does not require

 

2, C ++ struct and class in What is the difference?

1), struct members default to public, class defaults to public

2), struct inherit the default is public, class defaults to public

 

3, the difference between a reference and a pointer

Indirect pointer by the pointer variable operation target, the object and the reference is an alias, direct operation target

 

4. What is a multi-state

1), plus the virtual keyword, overridden in a derived class function prior to the base class, the runtime will be based on the actual type of the object

Call the appropriate function. If the object type is a derived class, the derived class is invoked; if the object type is the base class, the base class is called.

2), the presence of a virtual function of the class has a dimensional virtual function table called the virtual table, a pointer to the object class has virtual virtual table pointer begins. And the virtual table is corresponding to a class virtual table pointer is

Corresponding to the object and

 

Guess you like

Origin www.cnblogs.com/judes/p/11520650.html