利用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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值