菜鸟问题,求好心人解答。
#ifndef POINT_H
#define POINT_H
#include<iostream>
class Point{
public :
Point(int ,int );
Point(Point &);
~Point();
int get_x();
int get_y();
void put_x(int x);
void put_y(int y);
Point operator+(Point p);
Point operator*(int i);
Point operator>(Point p);
Point operator<(Point p);
int operator==(Point &p);
private :
int x;
int y;
friend istream& operator >> (istream & in , Point &p);
friend ostream& operator << (istream & out , Point &p);
}
#endif
类定义如上
使用vs2010进行编译
编译失败
log如下:
错误 1 error C2143: 语法错误 : 缺少“;”(在“&”的前面) x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
错误 2 error C2433: “istream”: 不允许在数据声明中使用“friend” x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
错误 3 error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
错误 4 error C2061: 语法错误: 标识符“istream” x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
错误 5 error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
错误 6 error C2805: 二进制“operator >>”的参数太少 x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
错误 7 error C2143: 语法错误 : 缺少“;”(在“&”的前面) x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
错误 8 error C2433: “ostream”: 不允许在数据声明中使用“friend” x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
错误 9 error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
错误 10 error C2061: 语法错误: 标识符“istream” x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
错误 11 error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
错误 12 error C2805: 二进制“operator <<”的参数太少 x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
错误 13 error C1004: 发现意外的文件尾 x:\code\vs\data struct\类定义\类定义\类定义.cpp 27
14 IntelliSense: 未定义标识符 "istream" x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
15 IntelliSense: 未定义标识符 "istream" x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
16 IntelliSense: 未定义标识符 "ostream" x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
17 IntelliSense: 未定义标识符 "istream" x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
#define POINT_H
#include<iostream>
class Point{
public :
Point(int ,int );
Point(Point &);
~Point();
int get_x();
int get_y();
void put_x(int x);
void put_y(int y);
Point operator+(Point p);
Point operator*(int i);
Point operator>(Point p);
Point operator<(Point p);
int operator==(Point &p);
private :
int x;
int y;
friend istream& operator >> (istream & in , Point &p);
friend ostream& operator << (istream & out , Point &p);
}
#endif
类定义如上
使用vs2010进行编译
编译失败
log如下:
错误 1 error C2143: 语法错误 : 缺少“;”(在“&”的前面) x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
错误 2 error C2433: “istream”: 不允许在数据声明中使用“friend” x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
错误 3 error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
错误 4 error C2061: 语法错误: 标识符“istream” x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
错误 5 error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
错误 6 error C2805: 二进制“operator >>”的参数太少 x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
错误 7 error C2143: 语法错误 : 缺少“;”(在“&”的前面) x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
错误 8 error C2433: “ostream”: 不允许在数据声明中使用“friend” x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
错误 9 error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
错误 10 error C2061: 语法错误: 标识符“istream” x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
错误 11 error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
错误 12 error C2805: 二进制“operator <<”的参数太少 x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
错误 13 error C1004: 发现意外的文件尾 x:\code\vs\data struct\类定义\类定义\类定义.cpp 27
14 IntelliSense: 未定义标识符 "istream" x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
15 IntelliSense: 未定义标识符 "istream" x:\code\vs\data struct\类定义\类定义\类定义.cpp 22
16 IntelliSense: 未定义标识符 "ostream" x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
17 IntelliSense: 未定义标识符 "istream" x:\code\vs\data struct\类定义\类定义\类定义.cpp 23
...全文
相关推荐
菜鸟宝典:局域网常见问题解答
菜鸟宝典:局域网常见问题解答电子书,基础教材!!!
解答你35个问题 让你买本不再菜鸟
本文将针对CPU、显卡和内存这三个关键组件解答一些常见的问题,帮助你更好地理解它们的特性和差异。首先,CPU方面:1.
菜鸟TO高手 帮助解决个人电脑问题
**常见问题解答**:列出一些常见电脑问题及其解决方案,如蓝屏、启动故障、软件冲突等。这个资源对于初学者来说是一份宝贵的指南,通过系统学习,他们可以从电脑新手逐步成长为能够独立解决问题的高手。
从Java菜鸟到专家的资料
通过系统学习和实践,不仅可以掌握Java语言,还能理解相关框架和工具,提升问题解决能力,从而成为一名专业的Java开发者。
清华尹成C语言从菜鸟到高手.pdf
"《清华尹成C语言从菜鸟到高手》是一本系统介绍C语言学习路径的教程,旨在帮助读者从零基础逐渐成长为C语言的高手。该书分为三个主要部分:C语言的基础入门、跨平台编程实践和深入理解数据类型、运算符与表达式


