加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c主要后的类声明?

发布时间:2020-12-16 10:24:02 所属栏目:百科 来源:网络整理
导读:#include "stdafx.h"using namespace System;class Calculater; // how to tell the compiler that the class is down there? int main(arraySystem::String ^ ^args){ ::Calculater *calculater = new Calculater(); return 0;}class Calculater{public: Ca
#include "stdafx.h"
using namespace System;

class Calculater; // how to tell the compiler that the class is down there? 

int main(array<System::String ^> ^args)
{
    ::Calculater *calculater = new Calculater();

    return 0;
}

class Calculater
{
public:
    Calculater()
    {
    }
    ~Calculater()
    {
    }

};

我在主要之后声明了这个类,我怎么告诉编译器我的类是什么?我试过了
class Calculater;在主要之前但它不起作用.

解决方法

你不能这样写它是怎么写的.编译器必须能够在使用它之前查看类的定义.您需要将您的类放在main函数之前,或者最好放在您包含的单独头文件中.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读