为了账号安全,请及时绑定邮箱和手机立即绑定

error C3867:“CMyClass::outCMyClass”: 函数调用缺少参数列表?

error C3867:“CMyClass::outCMyClass”: 函数调用缺少参数列表?

C++
弑天下 2023-01-03 18:14:56
#include <iostream>#include <vector>#include <iterator>#include <algorithm>using namespace std;class CMyClass{private:int m_nValue;public:static vector<CMyClass>member;CMyClass();CMyClass(int value);~CMyClass();static void ShowList();friend ostream & operator<<(ostream & output,const CMyClass & temp);void outCMyClass(const CMyClass& temp){ cout << temp << endl; }};int main(){CMyClass a(100);CMyClass b(1);CMyClass c;CMyClass *d = new CMyClass;*d = 10;cout << "The first end: " << endl;CMyClass::ShowList();if (1){CMyClass e(1000);cout << "The second end: " << endl;CMyClass::ShowList();}delete d;cout << "The third end: " << endl;CMyClass::ShowList();return 0;}CMyClass::CMyClass(){m_nValue = 0;member.push_back(*this);}CMyClass::CMyClass(int value){m_nValue = value;member.push_back(*this);}CMyClass::~CMyClass(){member.pop_back();}void CMyClass::ShowList(){for_each(member.begin(),member.end(),outCMyClass);}ostream & operator<<(ostream & output, const CMyClass & temp){output << temp.m_nValue;return output;}
查看完整描述

1 回答

?
慕容708150

TA贡献1831条经验 获得超4个赞

for_each(member.begin(),member.end(),outCMyClass);这一句有问题

因为这个函数一定要传一个参数的。

查看完整回答
反对 回复 2023-01-06
  • 1 回答
  • 0 关注
  • 103 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信