The reason why I want to write a function pointer is the extensive use of the function pointer in C + + programming, while for some beginners, the use of function pointers may be somewhat confusing, and once the function pointer is used at the
static variables and static functions in C.(1) The static variables in C are in the global store, which differs from the automatic variables stored in the stack. The key difference between the two is the difference in scope. The scope of an
1. Structure Size
int *pi = new INT[12]; pi is purely a pointer variable, it is a pointer to 4 bytes in a 32-bit environment, while the IA in int ia[]={0, 1, 2}, is a number group, although its value is the address of the first element, but it
Copy Code code as follows:
Class A
{
Public
Static Functiona ()
{
Menber = 1;
}
Privateint menber;}
There was an error compiling the above code. The reason is simple, as you all know, static member functions cannot
There are two main functions of keyword static in C language: scope and life cycle. For example, if you declare a function as static, you can restrict its scope to be valid for the current text, and declare a variable inside a function as static.
There are five existing areas of the program:A: The stack area in the dynamic regionB: The stack area in the dynamic regionC: Static zones: Global variables and static variables (this area can be further subdivided into: initialized global variables
1. Start by introducing itsThe first and most important article://Global variablevoid msg () {printf ( "hello\n "//main.c int main () {extern char A; // extern variable must be declared before use printf ( "%c " , a); (void) msg (); return 0
Static member: the member with the Static keyword added before the definition. As follows:classcrectangle{ Public: Crectangle (); ~Crectangle (); Static voidprinttotal ();Private: intW, H; Static intNtotalarea; Static intNtotalnumber;};
Turn from: https://www.cnblogs.com/hanyonglu/archive/2011/04/12/2014212.html make slight changesThis article describes the heap, stack, and static data areas in C + +. five large memory partitionsIn C + +, memory is divided into 5 extents, namely
Stacks , which are the stores of variables that are allocated by the compiler when needed, and automatically purged when not needed. The variables inside are usually local variables, function parameters, and so on. In a process, the user stack at
Declaration format for the class:Class class name identifier {[public:][data member Declaration] [Declaration of member function][private:][data member declaration] [Declaration of member function][protected:][declaration of data member]
# # #指针和引用的区别1. The pointer is a variable that stores the address pointing to the data, and the reference is simply an alias of the original variable, which is essentially the same as the original variable.2. Pointers can be multilevel, reference
A detailed description of C + + memory allocation-heap, stack, free storage, global/static storage, and constant storageStacks , which are the stores of variables that are allocated by the compiler when needed, and automatically purged when not
1. The first and most important article is to introduce it: hide. (static function, static variable all available)When multiple files are compiled at the same time, all global variables and functions that do not have a static prefix have global
If you try to use the member function of C + + directly ascallback functionAn error will occur, and even compilation will not pass.The error is that ordinary C + + member functions imply aThe recursive function acts as a parameter, that is, the
the usefulness of 1.this pointers:
The this pointer for an object is not part of the object itself and does not affect the results of the sizeof (object). This scope is within a class, when a non-static member of a class is accessed in a Non-static
One, design a class cannot be inherited
Method 1:Using static member functions ...Since a class cannot be inherited, that is, the constructor of the class cannot be accessed by the outside world, the constructor and destructor of the class need to
The function of virtual function in C + + is mainly to realize the mechanism of polymorphism. About polymorphism, in short, is to use the pointer of the parent type to an instance of its subclass, and then call the member function of the actual
One
an object model with single inheritance and no virtual functions
Class A
{public
:
int foo () { return val; }
static int Stafun () { return staval; }
static int staval;
Private:
int val;
char bit1;
} ;
Class
Explanation
There is no CV qualifier, and in C + + the CV qualifier refers to const and volatile.
Non-member function
In C + +, normal functions (non-class member functions) cannot have CV qualification, that is, const and volatile qualification.
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.