C + + should read the bookPaper Books Category:1, C + + programming language (Special Edition) Machinery Industry Press Qiu Zongyan (translation)2, C++primer (third edition, Chinese) China Power Publishing house Pan (translation)3, in-depth
Description: All code can be compiled and executed on Visual Studio 2013. did not test compilation on other compilers.
rules of the game
The gluttonous snake game requires the player to control the direction key (or Wsad key) to control the
the problem I found yesterday when I was doing the question
In normal inheritance, we can indicate in the initialization table of the current class (C) constructor How to construct a direct parent class (b), and then indicate how the ancestor class
function name and function pointer
A common function call
An example of a common function call:
Self-Contained header file
void myfun (int x); The declaration here can also be written as: void myfun (int);
int main (int argc, char*
A useful string IO operation: getline. This function takes two parameters: an input stream object and a string object. The Getline function reads from the next line of the input stream and saves the read content to string, but does not include line
C + + implementation of the head design pattern example (3 decoration mode)
The decorative pattern is the ability to dynamically extend an object without changing the original class file and using inheritance. It is by creating a wrapper object
#include #include using namespace std; Conversion between arbitrary transitions */** * S1 number before conversion * S2 number * D1 original number * D2 required to go to the number of numbers * above 9 digits in uppercase ' A ' ~ ' Z ', the 2~16
1. Why Use inline
On most machines, the calling function does a lot of work: Save the Register before the call, restore it on return, copy the arguments, and the program must also move to a new location to execute.
Use inline functions to avoid
definition of C + + function Overload:
In the same scope class , a set of functions have the same function name , the argument list is different (the number of parameters different/parameter types are different), the return value can be different
C + + typename usage
Directory
common usage of TypeName
For typename this keyword, if you are familiar with C + + templates, you will know that it has one of the most common uses (code is excerpted from C + + Primer):
Implement Strcmp-like
C + + provides a function template mechanism for us. The so-called function template, in fact, is to establish a common function, whose function type and parameter types are not specified, with a virtual type to represent. This generic function is
1. How to encapsulate your own DLL;
A. Open Visual Studio-file-New-project-class library-name Mytestdll;
B. Right key Class1.cs-modified to TestDll.cs;
C. write a function in it that you want to manipulate, such as:
public int Fnadd (int iAdd1, int
Several memory request functions commonly used in C language:
void* malloc (unsigned size);
void* realloc (void* ptr, unsigned newsize);
void* calloc (size_t numelements, size_t sizeofelement);
The above functions are defined in the header file
. NET defines the function of multithreading in the System.Threading namespace. Therefore, to use multiple threads, you must first declare a reference to this namespace (using System.Threading;).
Even if you do not have the experience of writing
Second-level pointers and three-level pointers as specific applications of formal parameters:
When a second pointer is used as a parameter, the memory allocation is performed outside the function. Functions only need to be related operations, the
A C-language program for Josephus problems
Problem Description:
n A person to sit around, starting from the first person to count "1,2,3,4....m, the number of m out of the people, and then the next person starting from 1 to continue, so until the
C language has a shift operation, but there is no cyclic shift operation.
For example, for a number a number 8, a loop to move left and right is as follows:
unsigned char a,b;
A = 0x0f;
b = a>> (8-3); /* Compensation left-shift missing bit/
a
12.24.cpp: Defines the entry point for the console application.
//
#include "stdafx.h"
#include
#include
#include
#pragma warning (disable:4996)
using namespace Std;
int main ()
{
String str;
cout CIN >> str;
Char *CP =
relatively simple generic Makefile for C + + program
Reference to the online data written by a simple can compile C + + mixed engineering Makefile "online most of the general makefile very long and no explanation, so write this document"
Have not
The following script, which defines two identical character arrays, prints out the value of result after comparison:Action () { int result; Char string1[] = "We can see the string:nancy"; Char string2[] = "We can see the string:nancy";
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