Take a look at the following code and ask whether print calls the base class or the version of the derived class?The answer is the base class...Maybe everyone will be surprised. Isn't print a virtual function? Why not call the version of the derived
See the following code:
Class {Public:A () {pvalue = new int [100]; printf ("constructor of A/N ");}~ A () {Delete [] pvalue; printf ("deconstructor of A/N ");}PRIVATE:Int * pvalue;};Class B {Public:~ B () {printf ("deconstructor of B/N ");}};
Class
The prototype of the string class is as follows:
Class string{Public:String (const char * STR = NULL );String (const string & other );~ String (void );String & operator = (const string & other );PRIVATE:Char * m_data;};
Implementation of the string
1. malloc and free are standard library functions of C ++/C, and new/delete are operators of C ++. They can be used to apply for dynamic memory and release memory.2. For non-Internal data objects, the use of maloc/free alone cannot meet the
A handle is the identifier of a window resource. It identifies the memory block occupied by the resource in the system. The application operates the window through the window handle. In addition to the window handle, any kind of resource has its own
High-quality programming guide: C ++/C LanguageBasic InformationAuthor: Lin Rui Han Yongquan [Translator's introduction]Press: Electronic Industry PressISBN: 9787121186172Mounting time:Published on: February 1, October 2012Start: 16Page number:
Original article link
Applications can be viewed in graphicsProgramAs a learning experience. This helps you understand the internal behavior of an application and obtain information about program optimization. For example, by optimizing frequently
C ++ class and object details, object details
1. What is a class?
1-1 Development of Program Design
1-2 process-oriented to object-oriented
1-3 class definitions
1-4 constructor destructor
I. constructor and destructor
C ++ functions written behind the scenes for you: A copy constructor, a value assignment operator, a destructor, and a pair of access operators. In addition, if you do not declare any constructor, it will also declare a
Component Programming does not abandon traditional object-oriented programming. On the contrary, component programming is the deepening and development of object-oriented programming. As the soul of object-oriented language, class has been widely
Needless to say, this is about Operator overload. About operator, the description in can be used as a overload as follows:+ */% ^ & | ~ ! = + = *=/=%= ^= &= |= > >>= >= && | | + + >*, > [] () new new[] Delete delete[]Start with operator = speak
LeeLin blog
(1) When the base class does not have its own constructor, the default bar of the derived class uses the constructor of the base class.(2) When the base class has a self-compiled constructor, you must add a constructor without parameters
Virtual functions are used in C ++ to implement polymorphism. The core concept is to access the functions defined by the derived class through the base class. Suppose we have the following class layers:Class{Public: Virtual void Foo () {cout
1. New is the operator in C ++, and malloc is a function in C.2. New not only allocates memory, but also calls class constructor. Similarly, delete calls class destructor, while malloc only allocates memory, does not initialize class members, or
I. Purpose of introducing inheritance
1. code reuse
The Inheritance and derivation mechanisms of classes enable programmers to get new classes by adding a small amount of code or modifying a small amount of code on the basis of existing classes
(1) When the base class does not have its own constructor, the default bar of the derived class uses the constructor of the base class.(2) When the base class has a self-compiled constructor, you must add a constructor without parameters to the base
Virtual functions in C ++)
1. Introduction
Virtual functions are used in C ++ to implement polymorphism. The core concept is to access the functions defined by the derived class through the base class. Suppose we have the following class
8.4 exceptions
Exception
An error that cannot be ignored occurs when other parts of the exception notification program are used.
An exception is thrown only when the exception is true.
Do not shirk responsibility with exceptions
Avoid throwing
Similarities: Can be used to apply for dynamic memory and release memory
Differences:(1)Different operation objects.Malloc and free are standard library functions in C ++/C, and new/delete are operators in C ++. For non-Internal data objects,
C ++ proverbs: Understand the inline-based intervention and exclusion-Linux general technology-Linux programming and kernel information. The following is a detailed description. Inline functions-Great idea! They look like functions, and they produce
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.