1个无法解析的外部命令

wch328 2014-10-17 12:32:17
#include<iostream>
using namespace std
class aClass
{public:
aClass ()
{total++;
}
~aClass()
{total--;
}
int gettotal()
{return total;
}private:
static int total
};
int aClass::total=0;
int main()
{aClass o1,o2,o3;
cout<<o1.gettotal()<<"objects in existe\n";
aClass*p;
if(!p)
{cout<<"Allocation error\n";
return 1;
}
cout<<o1.gettotal();
cout<<“objects in existence after allocation\n";
delete p;
cout<<o1.getttotal();
cout<<"objectd in existence after deletion\n";
return 0:
}
调试时出现错误:1个无法解析的外部命令
...全文
135 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
铖邑 2014-10-17
  • 打赏
  • 举报
回复
那个private可以留着,一楼贴出来的代码,可以编译
漫舞云中影 2014-10-17
  • 打赏
  • 举报
回复
引用 2 楼 u011836122 的回复:
引用 楼主 wch328 的回复:
错了一大堆标点符号。 拼错了一个getttotal。
漫舞云中影 2014-10-17
  • 打赏
  • 举报
回复
引用 楼主 wch328 的回复:
#include<iostream> using namespace std class aClass {public: aClass () {total++; } ~aClass() {total--; } int gettotal() {return total; }private: static int total }; int aClass::total=0; int main() {aClass o1,o2,o3; cout<<o1.gettotal()<<"objects in existe\n"; aClass*p; if(!p) {cout<<"Allocation error\n"; return 1; } cout<<o1.gettotal(); cout<<“objects in existence after allocation\n"; delete p; cout<<o1.getttotal(); cout<<"objectd in existence after deletion\n"; return 0: } 调试时出现错误:1个无法解析的外部命令
把第一个标红的地方的private去掉。 第二个标红的地方:你没有拼错? 还有,你好几个地方标点符号有问题,不知道是不是你代码粘贴的问题?
铖邑 2014-10-17
  • 打赏
  • 举报
回复
少一些符号,很多中文符号 // eee.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> using namespace std; class aClass {public: aClass () {total++; } ~aClass() {total--; } int gettotal() {return total; } private: static int total; }; int aClass::total=0; int main() {aClass o1,o2,o3; cout<<o1.gettotal()<<"objects in existe\n"; aClass*p; if(!p) {cout<<"Allocation error\n"; return 1; } cout<<o1.gettotal(); cout<<"objects in existence after allocation\n"; delete p; cout<<o1.gettotal(); cout<<"objectd in existence after deletion\n"; return 0; }
勤奋的小游侠 2014-10-17
  • 打赏
  • 举报
回复
拼错函数名了呗

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧