vector 容易包含自定义类型 的错误,请求大家帮忙。

yaozhenyu8211 2009-06-02 03:33:04
#include "stdafx.h"
#include "iostream"
#include <ostream.h>
#include <istream.h>
#include <vector>
//using std::cout;
//using std::endl;
//using namespace std;
class student
{
public:
student(int s)
{
score=s;
}
int getpoint() const
{
return score;
}
void setpoint(int k)
{

score=k;
}
student(const student &rhs)
{
this->score=rhs.getpoint();
}
student& operator=(const student &rhs)
{
if (this->score==rhs.getpoint())
return *this;
else
{
this->score=rhs.getpoint();
}
return *this;
}
public:
friend bool operator==(const student &lhs,const student &rhs)
{
int g=rhs.getpoint();
int j=lhs.getpoint();
if(g==j)
return true;
else
return false;
}
friend ostream& operator<<(ostream &os,const student &rhs)
{
os<<rhs.getpoint();
return os;

}
friend istream& operator>>(istream &in, student &rhs)
{
int h;
in>>h;
if(in)
{
rhs.setpoint(h);
}
return in;
}
private:
int score;
};

int main(int argc, char* argv[])
{

vector<student> vec; //
cout<<"please input a score"<<endl;
student input(10);
while(cin>>input)
{

}
return 0;
}



发生的错误提示:error C2065: 'vector' : undeclared identifier
D:\vc\s\s.cpp(93) : error C2275: 'student' : illegal use of this type as an expression
D:\vc\s\s.cpp(13) : see declaration of 'student'
D:\vc\s\s.cpp(93) : error C2065: 'vec' : undeclared identifier

...全文
98 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yaozhenyu8211 2009-06-02
  • 打赏
  • 举报
回复
不好意思了。先回答的分多点。呵呵 。
yshuise 2009-06-02
  • 打赏
  • 举报
回复

using namespace std;
coverallwangp 2009-06-02
  • 打赏
  • 举报
回复
std::vector
或者开头写
using std::vector
「已注销」 2009-06-02
  • 打赏
  • 举报
回复
std::vector
ykdoubles 2009-06-02
  • 打赏
  • 举报
回复
std::vector

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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