利用VS2008中的C++程序

利用VS2008中的C++程序編寫
技巧說明
1.跳出消息說明爲System::Windows::Forms::MessageBox::Show();
2.類的屬性聲明爲 private: static int i=0;必須添加static
3.控件屬性爲this->label1->Text
4.C++沒有null這個標記符
5.對於類型的new一般設置爲gcnew
6.線程的定義爲private: static System::Threading::Thread^  threadtest;
7.在string類型在C++中是#include <string>和using namespace std;
聲明字符串是  std::string這是VC6.0中的定義
8. 利用VS2008中的字符串定義
System::String^   test="hello world!";
System::Windows::Forms::MessageBox::Show(test);
9.數組的定義。
 整型數組定義     System::Int32 a[10];
字符串數組定義  array<System::String^>^  StrArray;
array<System::String ^> 是System::String的泛類.其實就是個字符串數組
例子:array<System::String^,2>^ doubleArray=gcnew array<System::String^,2>(2,2);
整型定義              System::Int32 a;

10.Std:string與System::String ^相互轉換
std::string ConvertToString(System::String^ str)
{
 int q=(int)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str);
 char* p=(char*)q;
 return std::string(p);
}
主要是爲了unicode到ansi的轉換
11.
::的含義:
^的含義:類型名稱String後面的字符^表示這是引用String類型對象的句柄。

12. array與System:Array是不相同的

13.C#中的new 與VC++中的gcnew

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章