In Java:
|
Data Type |
Size |
Minimum value |
Maximum Value |
|
byte |
8-bit (one byte) |
-128 |
+ 127 |
|
char |
16-bit (2 bytes) |
Unicode 0 |
Unicode 2 16 - us ">-1 |
|
short |
16-bit (2 bytes) |
-2 15 |
+ 2 15 - us ">-1 |
|
int |
32-bit (4 bytes) |
-2 31 |
+ 2 31 - us ">-1 |
|
float |
32-bit (4 bytes) |
ieee754 |
ieee754 |
|
long |
64-bit (8 bytes) |
-2 63 |
2 63 -1 |
|
Double |
64-bit(8 bytes) |
Ieee754 |
Ieee754 |
In VC:
|
|
Type |
Default size |
Description |
|
Base
Foundation
Class
Type
All
Yes
Small
Write
|
Note: These basic data types are supported for both MFC and API. |
|
Boolean (numeric type) |
Unsigned 8 bit, |
Value: True/false |
|
Byte |
Unsigned 8 bit, |
Integer, output by character |
|
Char |
Unsigned 8 bit, |
Character |
|
Double |
Signed 64 bit |
Floating Point Type |
|
Float |
Signed32 bit |
Floating Point Type |
|
Handle_t |
|
Primitive handle type |
|
Hyper |
Signed 64 bit |
Integer |
|
Int |
Signed 32 bit |
Integer |
|
Long |
Signed 32 bit |
Integer |
|
Short |
Signed 16 Bit |
Integer |
|
Small |
Signed 8 bit |
Integer |
|
Void * |
32-bit |
Pointer to unknown type |
|
Wchar_t |
Unsigned 16 Bit |
16 characters, more characters than char |
|
|
|
|
|
Win32
API
Regular
Use
Quantity
Data
Class
Type
All
Large
Write |
Note: The simple data types supported by these win32apis are mainly used to define function return values, message parameters, and structure members. This type of data can be roughly divided into five categories: struct, Boolean, integer, pointer, and handle (?). There are about 100 different types in total, |
|
Bool/Boolean |
8bit, true/false |
Boolean |
|
Byte |
Unsigned 8 bit |
|
|
BSTR
Ccombstr
_ Bstr_t |
32 bit |
BSTR is a 32-bit pointer to a string.
Is encapsulation of BSTR
Is encapsulation of BSTR |
|
Char |
8 bit |
(ANSI) character type |
|
Colorref |
32 bit |
Integer RGB color value |
|
DWORD |
Unsigned 32 bit |
Integer |
|
Float |
Float Type |
Float Type |
|
Handle |
|
Object handle |
|
Hbitmap |
|
Bitmap handle |
|
Hbrush |
|
Brush handle |
|
Hcursor |
|
Cursor handle |
|
HDC |
|
Device context handle |
|
Hfile |
|
File handle opened by openfile |
|
Hfont |
|
Font handle |
|
Hhook |
|
Hook handle |
|
Hkey |
|
Registry Key handle |
|
Hpen |
|
Pen handle |
|
Hwnd |
|
Window handle |
|
Int |
-------- |
-------- |
|
Long |
-------- |
--------- |
|
Longlong |
|
64-bit signed integer |
|
Lparam |
32 bit |
Message Parameters |
|
Lpbool |
|
Bool pointer |
|
Lpbyte |
|
Byte pointer |
|
Lpcoloref |
|
Colorref pointer |
|
Lpcstr/lpstr/pcstr |
|
Pointing to an 8-bit (ANSI) string type pointer |
|
Lpcwstr/lpwstr/pcwstr |
|
Point to a 16-bit Unicode string type |
|
Lpctstr/lptstr/pctstr |
|
Pointer to an 8-or 16-Bit String |
|
Lpvoid |
|
Point to a 32-bit pointer of an unspecified type |
|
Lpdword |
|
Pointing to a DWORD pointer |
|
Other similar types: lphandle, lpint, lplong, lpword, lpresult
Pbool, pboolean, pbyte, pchar, pdword, pfloat, phandle, pint, plong, Pshort ......
Note: (1) in a 16-bit system, the LP is 16bit, the P is 8bit, and the 32-bit system is 32bit (equivalent at this time)
(2) c in lpcstr indicates Const. t indicates tchar mode, which can work in ANSI or Unicode. |
|
Short |
Usigned |
Integer |
|
Other uchar, uint, ulong, ulonglong, and ushort types are unsigned. |
|
Tbyte |
|
Wchar or char |
|
Tchar |
|
Both ANSI and Unicode |
|
Variant
_ Variant_t
Colevariant |
|
For a struct, refer to IDL. h.
_ Variant_t is the encapsulation class of variant.
Colevariant is also a variant encapsulation class. |
|
|
|
|
|
|
|
|
|
Wndproc |
|
32-bit pointer to a window Process |
|
Wchar |
|
16-bit Unicode Character Type |
|
Word |
|
16-bit unsigned integer |
|
Wparam |
|
Message Parameters |
|
MFC
Exclusive
Data
Type |
The following two data types are unique in the Microsoft basic library. |
|
Position |
The value that marks the position of an element in the set. It is used by the collection class in MFC. |
|
Lpcrect |
A 32-bit pointer pointing to a rect struct constant (which cannot be modified) |
|
Cstring |
It is actually a class in MFC. |
|
|
|
|
Differences between Java and C ++
1. the Boolean and INT types in Java are incompatible, that is, they cannot be converted to each other, and the true and fasle values of the boolean type cannot be compared to the size;In C ++, true = 1; false = 0; (true & gt; flase) = 1;
2. in Java, the char type is 16-bit, that is, two bytes;In C ++, the char type is 1 byte, that is, 8 bits.
3. In Java expressions, the char, byte, and short types are automatically converted to the int type, that is, the int type variables generated by adding the two byte types. The following definitions define byte b1 = 1, b2 = 2, B3; to assign B3 to the sum of B1 and B2, you must write B3 = (byte) (b1 + b2 ); because B1 + B2 is int type, the compiler reports an error if the conversion type is not forced.In C, the char, byte, and short types are not automatically converted to the int type.
4. in Java, integers are of the int type by default and decimals are of the double type by default. The Char, byte, and short variables can be directly assigned as integers without changing the type. The long variable must be assigned with the suffix L, the suffix F must be added when the float variable is assigned a decimal number. (If the float value is not assigned a suffix, an error is returned ). For example, long T1 = 20l; float F1 = 2.3f; type conversion in C ++ is not very strict;
5. the expressions used to control statements in Java must be of the Boolean Type and cannot be of the int type, because they are incompatible. c ++ can both;
6. If there is no pointer in Java, type name [] is used to declare the array. The number cannot be entered in. Name has a length member to indicate the size of the array. In C ++, the array [] can be entered with a number. Generally, an array of the type does not have a length member. Java can initialize such as type name [] = {New Type (), new type (),..., New Type ()}; an array of simple type (such as INT) can be directly assigned a value in. In C ++, the multi-dimensional array in a simple type of Java uses the two-dimensional array int type as an example. int A [] [] = new int [2] [], that is, the second-dimension can be unstated first, then you can declare an irregular array, that is, a [0] = new int [1]; A [1] = new int [2]; A [3] = new int [3]; c ++ arrays of medium and high dimensions cannot be dynamically allocated and can only be statically allocated. Therefore, irregular arrays cannot be implemented.
7. the method in the inheritance class in Java is equivalent to the virtual function in C ++, and the abstract method in Java is equivalent to the pure virtual function in C ++, classes that contain abstract methods in Java must be declared as abstract classes, that is, abstract modifiers must be added before classes. At this time, this class cannot be instantiated, And the generated subclass must override the superclass (that is, the parent class) otherwise, the subclass cannot be instantiated and must be explicitly declared as the abstract class. The abstract class is not required in C ++.
8. A referenced variable of a super class in Java can reference a subclass instance, which is equivalent to a pointer to a C ++ base class and can point to an instance of a derived class. Similarly, although the reference of a super class points to a subclass, some members or methods in the subclass are not in the superclass, and sometimes the reference of the super class is still unavailable. This is also true in C ++. The base class pointer is used to generate the object of the derived class, but the pointer must be owned by the base class.
9. in Java, if the two variables str1 and str2 of string (s capital when declaring the type) are equal, it means that they reference the same string (equivalent to using the same memory ), to indicate that the two independent variables contain the same strings, the string class can be called using the Boolean equals (string Str) method. That is, if the value of str1.equeals (STR) is true, str1 and str2. There are other methods for string:
Boolean equals (string Str)
If the call string contains the same character sequence as STR, true is returned.
int length ()
obtain the length of a string
char charat (INT index)
character used to obtain the index location specified by index
int compareto (string Str)
If the call String is smaller than STR, a number smaller than 0 is returned. If the call String is greater than 0, a number greater than 0 is returned; 0
int indexof (string Str)
returns the first str-matched index in the call string, if no match exists,-1 is returned.
int lastindexof (string Str)
returns the last str-matched index in the call string, if no match exists,-1 is returned.
in C ++, if str1 = str2 is 1, The str1 string is equal to the str2 string, they can be independent