TIPS: VC ++

Source: Internet
Author: User

 Vs2005 does not find the perfect solution for msvcr80d. dll

Method 1. Choose "Project Properties"> "configuration properties"> "configuration tools"> "general"> "FAT32 solution" and select "yes ";
Method 2. Find the. rec file under the DEBUG directory of the project, delete (or delete the entire DEBUG directory) and re-compile the file;
Method 3. http://www.cnblogs.com/qianinsun/archive/2006/12/01/579182.html

 

 Byte alignment
# Program pack (x) // x = 1, 2, 4, 8, 16... the default value is 8.
Whenever a member variable of a structure needs to be located, take the length of the member variable and the minimum value in the middle of X as the standard. The offset of the member variable must be divisible by the value. After all the Members are located, take the length of the widest member in the struct and the minimum value in the middle of X as the standard again. The size of the entire struct must be divisible by this value.

 

 . NET environment programming tip

Any. all programs written in the. NET environment must be installed.. NET Framework (note that programs written in C ++ are not required by default. net Framework CLR is run. By developing a new switch, the C ++ compiler can also generate a managed module that requires CLR execution ), we can find mscoree in the % WINDIR %/system32 directory. DLL file to determine whether the machine is installed.. NET Framework. If yes, it indicates that it has been installed. If you want to determine which versions of the. NET Framework are installed, you can view the subkeys under the following registry keys:

HKEY_LOCAL_MACHINE/software/Microsoft/. netframework/Policy

 

 C vs. net

During the C language runtime, heap allocation memory is based on linked lists, while. Net CLR managed heap allocation is based on contiguous memory blocks. Therefore,. net allocation objects are much faster than C;
. NET will use the memcpy function to compress the hosted heap after garbage collection, so it will bring a lot of performance damage to the application, and its performance is lower than that of the heap during C runtime.

 

 Forced type conversion of pointer

In the forced type conversion of pointer: ptr1 = (type *) ptr2, if sizeof (ptr2 type) is greater than sizeof (ptr1 type ), therefore, it is safe to use the pointer ptr1 to access the storage zone pointed to by ptr2. If sizeof (ptr2 type) is smaller than sizeof (ptr1 type), it is insecure when ptr1 is used to access the bucket to which ptr2 points.

 

 The Microsoft C compiler (cl.exe for 80x86) in win32platform uses the following alignment rules by default.

The alignment modulus of any basic data type T is the size of T, that is, sizeof (t ). For example, for the double type (8 bytes), it is required that the address of this type of data is always a multiple of 8, and the char type data (1 byte) can start from any address. In Linux, GCC adopts another set of rules (not verified in the data, please correct the error): Any 2-byte size (including single-byte ?) The alignment modulus of data types (such as short) is 2, while all other data types (such as long and double) that exceed 2 bytes are 4 as alignment modulus.

 

 "Precise guidance"

By disabling a local scope (such as a pair of curly braces "{}"), you can precisely control when variable destructor are called.

 

 Abstract class

Abstract classes cannot define objects. In practice, to emphasize that a class is an abstract class, you can describe the constructor of this class as a protected access control permission.

An abstract class can only be used as a base class. The implementation of its pure virtual function is provided by the derived class. If the derived class does not redefine the pure virtual function, and the derived class only inherits the pure virtual function of the base class, the derived class is still an abstract class. If the implementation of the basic class pure virtual function is provided in the derived class, the derived class is no longer an abstract class. It is a concrete class that can create objects.

 

 Class non-built-in class member Initialization

The initialization of non-built-in class (such as string type) members is in the (1) form, which is about 30% more efficient than the method (2;
Form (1 ):
Employee: employee (const string & nm): Name (Nm ){}
Form (2 ):
Employee: emplogyee (const string & nm) {name = Nm ;}
Form (2) performs two string operations on the name Member (one initialization and one assignment ).

 

 ...

When both operands are operational input and none are affected by the operation, we 'd better define the operator as a non-member function. In this way, the two operands can be operated in the same way under the conditions of implicit conversion.

 

 ...

It is invalid to pass an unnamed temporary object as a constant pointer to a function as a parameter.

 

 ...

If the destructor in the base class is not virtual, the deletion action using a pointer cannot call the destructor in the correct derived class.

 

 Macro character #

# Is a string operator that converts macro parameters to string constants.

 

 Visual Studio shortcut
Crtl + J input completion
Crtl + k, crtl + I outgoing call notifications
Crtl + k, crtl + P outgoing call parameter information
Shift + ALT + O find the file (bytes X ?)
Crtl + I Quick Search
Crtl + Shift + V call out the last 20 clipboard records
Crtl + W select the word of the cursor
CTRL + M, CTRL + M fold code
Crlt + M, CTRL + l fold all code of the file
Crtl + l cut rows
CTRL + Shift + L Delete rows
Alt + G jump to function definition/previous and next Cursor Position switch

 

 How does VC load a bitmap from the hard disk:
Hbitmap hbmp;
Cbitmap bitmap;

Hbmp = (hbitmap): LoadImage (AfxGetInstanceHandle (), "./RES/bv.bmp", image_bitmap, 0, 0, lr_loadfromfile );
Bitmap. deleteobject ();
If (! Bitmap. Attach (hbmp ))
{
Afxmessagebox ("error to attach a bitmap ");
}

 

 ASCII special characters

Values 8, 9, 10, and 13 can be converted into backspace characters, tabs, linefeeds, and carriage returns. These characters are not graphically represented, but for different applications, these characters may affect the text display effect.

 

 Programmable memory type

The programmable memory can basically be divided into the static storage area, heap area, and stack area. Their functions are different, so they are used differently.
Static storage zone: it is allocated when the program is compiled, and the existing program exists throughout the runtime. It stores static data, global data, and constants.
STACK: When a function is executed, the storage units of local variables in the function can be created on the stack. When the function execution ends, these storage units are automatically released. Stack memory allocation computation is built into the processor's instruction set, which is highly efficient, but the memory capacity allocated is limited.
Heap area: Also known as dynamic memory allocation. When the program runs, it uses malloc or new to apply for memory of any size. The programmer is responsible for releasing the memory with free or delete when appropriate. The lifetime of the dynamic memory can be determined by us. If we do not release the memory, the program will only release the dynamic memory at the end. However, a good programming habit is: if a dynamic memory is no longer used, it needs to be released. Otherwise, we think there is a memory leak.
The biggest difference between heap, stack, and static storage is that the stack life cycle is short. However, the life cycle of the heap and static storage areas is equivalent to the same as that of the Program (if you delete the heap memory before running the program ), we convert this variable or data into a global variable or data.

 

 Use precompiled files in
1. Set the name of the pre-compiled file at the project level, set the name of the pre-compiled header file (such as stdafx. H), and set the project Yu ("used") mark;
2. At the file level (such as stdafx. cpp), set the pre-compilation header generated by the file and set the YC ("generated") mark of the file;
3. to generate the pre-compiled header XXX. PCH, you only need to select the above file (stdafx. cpp) and compile it separately.

 

 Using namespace Scope
Which file writes using namespace STD, And that file introduces this namespace, which has nothing to do with other files.

 

 Install vs2003 FAQ
1. The registry cannot be read or written during installation.
Delete HKEY_LOCAL_MACHINE/system/CurrentControlSet/control/Session Manager/pendingfilerenameoperations in the registry;
2. An error occurred while reading accessibility after installation.
Copy: C:/Windows/Microsoft. NET/framework/v1.1.4322/accessibility. DLL to: C:/program files/Microsoft Visual Studio. NET 2003/common7/IDE/to solve the problem;
Or reinstall Microsoft. NET Framework;

 

 Difference between fopen binary ("B") and text ("T ")
The binary method is very simple. When reading a file, it will read all the content of the file in an intact manner. When writing, it also writes the content of the memory buffer to the file.
The text format is different. When writing a file, the newline character CRLF (0x0d 0x0a) is converted to a single 0x0a, and when the terminator ctrlz (0x1a) is encountered, it is deemed that the file has ended. Correspondingly, when writing a file, all 0x0a is replaced with 0x0d0x0a.

 

 

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.