| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2838 人关注过本帖
标题:弱弱地问一下,托管的C++应用程序?
只看楼主 加入收藏
树上的番茄
Rank: 1
来 自:湖南
等 级:新手上路
帖 子:32
专家分:0
注 册:2008-3-1
收藏
 问题点数:0 回复次数:0 
弱弱地问一下,托管的C++应用程序?
小弟装得是
找了半天就是没有找到有新建托管得C++应用程序这个项目!
只得建了个 控制台应用程序(.net)
编译有问题!
// 这是使用应用程序向导生成的 VC++
// 应用程序项目的主项目文件。

#include "stdafx.h"
#include <string.h>

#using <mscorlib.dll>
#include <tchar.h>
using namespace System;

 _gc class animal
{
public:
    int legs;
    void SetName(String *Name){strName=Copy(Name);};
    String *GetName(){return strName;};

private:
    String *strName;

};


int _tmain(void)
{
    // TODO: 请用您自己的代码替换下面的示例代码。
    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;
}

e:\My Documents\Visual Studio Projects\animals\animals.cpp(12): error C2143: 语法错误 : 缺少“;”(在“<类头>”的前面)
e:\My Documents\Visual Studio Projects\animals\animals.cpp(12): error C2501: “_gc” : 缺少存储类或类型说明符
e:\My Documents\Visual Studio Projects\animals\animals.cpp(19): error C3265: 无法声明托管“strName”(在非托管“animal”中)



这2个项目有什么差别????

还好 小弟得编译器是不是少了某些东西?
搜索更多相关主题的帖子: 应用程序 托管 
2008-07-16 18:19
快速回复:弱弱地问一下,托管的C++应用程序?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016533 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved