VC++ .NET 2003学习
来源:互联网 发布:云计算的行业应用 编辑:程序博客网 时间:2024/06/09 15:58
先学习了一个例子,面向对象的
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
__gc class Animal
{
public:
int legs;
void SetName(String *name)
{ strName = strName->Copy(name); }
String* GetName() { return strName; }
private:
String *strName;
};
int _tmain()
{
// TODO: Please replace the sample code below with your own.
Animal *cat, *dog;
cat = new Animal;
dog = new Animal;
cat->SetName("Cat");
cat->legs = 4;
dog->SetName("Dog");
dog->legs = 4;
Console::WriteLine("Animal 1");
Console::Write("Name: ");
Console::WriteLine(cat->GetName());
Console::Write("Legs: ");
Console::WriteLine(cat->legs);
Console::WriteLine();
Console::WriteLine("Animal 2");
Console::Write("Name: ");
Console::WriteLine(dog->GetName());
Console::Write("Legs: ");
Console::WriteLine(dog->legs);
Console::WriteLine();
return 0;
}
很好的一个例子,用到了托管代码,__gc,要注意的是,调试时,用到了托管代码,所以要在
项目->属性->c/c++选项->常规->编译为托管 选择 程序集支持 (/clr)
就可以了,值得初学者注意
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
__gc class Animal
{
public:
int legs;
void SetName(String *name)
{ strName = strName->Copy(name); }
String* GetName() { return strName; }
private:
String *strName;
};
int _tmain()
{
// TODO: Please replace the sample code below with your own.
Animal *cat, *dog;
cat = new Animal;
dog = new Animal;
cat->SetName("Cat");
cat->legs = 4;
dog->SetName("Dog");
dog->legs = 4;
Console::WriteLine("Animal 1");
Console::Write("Name: ");
Console::WriteLine(cat->GetName());
Console::Write("Legs: ");
Console::WriteLine(cat->legs);
Console::WriteLine();
Console::WriteLine("Animal 2");
Console::Write("Name: ");
Console::WriteLine(dog->GetName());
Console::Write("Legs: ");
Console::WriteLine(dog->legs);
Console::WriteLine();
return 0;
}
很好的一个例子,用到了托管代码,__gc,要注意的是,调试时,用到了托管代码,所以要在
项目->属性->c/c++选项->常规->编译为托管 选择 程序集支持 (/clr)
就可以了,值得初学者注意
- VC++ .NET 2003学习
- VC++ .NET 2003学习
- 学习vc++2005.net
- vc.net 学习
- VC++ .Net 实例学习
- VC++.NET学习笔记(续)
- vc.net学习笔记1
- VC++.NET学习笔记(第二章)
- VC++.NET学习笔记(第三章)
- VC++2005.net 学习笔记(一)
- VC++.NET技术内幕学习一
- VC++.NET 技术内幕学习二
- VC++.NET 技术内幕学习三
- VC++.NET 技术内幕学习四
- VC.NET 2003 优化选项
- 对学习VC学习.net的粗浅建议
- vc.net
- vc.net
- eclipse下的打包插件fatjar
- sql server 2005 中的同义词
- iOS ARC详解
- ifconfig 源码
- DevExpress VCL 13.1触摸体验增强
- VC++ .NET 2003学习
- (转)禁止QQ直播、p2p软件的方法
- vs2010 drag class to classdiagram not working
- 单机同时提供VMWARE LIUNX+WIN2000的IP访问
- PHP 5.0 Pear安装方法
- (转)JDK 1.5中的ENUM用法
- 世界前五大IT咨询公司
- ASP.NET 2.0中XSLT的使用
- 高位优先与低位优先