C + + syntax notes
Notes (C + +)
This article has some knowledge of C + + syntax and object-oriented, involving the bottom of assembly.
1. Essential differences between programming languages
Compiled language (independent of virtual machine)scripting language Compiled language (virtual machine dependent)C,C++,object-CPHP,Python,JavaScriptJava,Ruby
C + + cod ...
Added by champoi on Sun, 20 Feb 2022 05:51:31 +0200
share_ptr memory leak
Here is shared_ There are three common ways to define PTR: shared_ptr sp;// Declare a smart pointer to type int
sp.reset(new int(42));
auto sp1 = make_shared<string>("hello");//sp1 is a smart pointer
shared_ptr sp2(new int(42));
And make_ The shared method is a recommended one. It uses one-time allocation and is relatively safe. We all ...
Added by aquila125 on Sun, 20 Feb 2022 05:31:38 +0200
C + + operation, please design a program to realize the management of book inventory (dynamic array class)
[problem description]
Please design a program to realize the management of book inventory. Please complete the design according to the given main function and program output. The specific requirements are as follows.
1, Please design a Book Class:
1. Include private members:
unsigned int m_ID;//number
string m_Name;//title
string m_Introd ...
Added by NovaHaCker on Sun, 20 Feb 2022 04:28:42 +0200
Encapsulate C++ dll with CLR
Reasons for project proposal
A dynamic link library is written in C + +, which contains h/.lib/.dll three files, but many users use C # to program. At this time, it is necessary to provide a dll that C # can call. There are generally two methods for C # to call dll, namely
dllimport is used to encapsulate functions, but according to the relev ...
Added by Bind on Sun, 20 Feb 2022 03:32:25 +0200
Differential-Prefix Sum
Prefix sum is an important preprocessing tool in the algorithm.
Okay, I can't make it up anymore, it seems I don't have any [doge]
Differential operations, which can be said to be the inverse of the sum of prefixes, are often used together with the prefix to solve some interval problems.
Recently, I also encountered a lot of diffe ...
Added by jtp51 on Sun, 20 Feb 2022 03:14:19 +0200
C + + Design Pattern -- Bridge pattern
Single responsibility mode: in the design of software components, if the division of responsibilities is not clear, the result of using inheritance is often that the subclass expands sharply with the change of requirements and is full of repeated code. At this time, the key is to clarify the responsibilities. Typical mode • Decorator • Bridge ...
Added by tweek on Sun, 20 Feb 2022 01:55:24 +0200
Use of custom data types struct, enum and union
1, Structure: a set of data representing a specific meaning is always stored Features: it encapsulates data (function encapsulates function) Benefits: 1 Improve code readability 2. Improve data usability 3. Improve code maintainability Structure definition format:
struct +Structure name
{
Element 1;
.....
}
Structure definition structure va ...
Added by expertis on Sat, 19 Feb 2022 23:22:10 +0200
Logical question: ex wife and stephusband, whose son inherits the rich man's estate
preface
The author searched for a long time and didn't find the right answer, so he wrote a c + + program to traverse all the possibilities
The title and code are as follows
1, Title
Once upon a time, there was a rich man who had 30 children, of which 15 were born to his late ex-wife and the other 15 were born to his stepwife. T ...
Added by leequalls on Sat, 19 Feb 2022 21:27:53 +0200
Class and object knowledge points
C + + will provide a default constructor, destructor and default copy constructor
Shorthand method of constructor
CCylinder(double r,double h)
{
radius=r;
height=h;
};
==>CCylinder(double r,double h):radius(r),height(h){}
[this method is limited to constructors]
Allocate space during construction and release space during deco ...
Added by kbrij on Sat, 19 Feb 2022 17:43:56 +0200
Multiple acting classes and objects
catalogue
1, Understanding of class
2, Access qualifier and encapsulation of class
3, Scope and instantiation of class
4, Calculation of object size of class
5, this pointer of class member function
6, Constructor
7, Destructor
8, Copy constructor
9, Operator overloading
10, Implementation of date class
Get the number of days per mon ...
Added by Cory94bailly on Sat, 19 Feb 2022 15:19:51 +0200