c主要后的类声明?

c主要后的类声明?,第1张

概述#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
#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函数之前,或者最好放在您包含的单独头文件中. 总结

以上是内存溢出为你收集整理的c主要后的类声明?全部内容,希望文章能够帮你解决c主要后的类声明?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1219864.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-05
下一篇2022-06-05

发表评论

登录后才能评论

评论列表(0条)

    保存