| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 355 人关注过本帖
标题:c++友原问题。。。
只看楼主 加入收藏
陈便往
Rank: 2
等 级:论坛游民
帖 子:61
专家分:32
注 册:2011-9-21
结帖率:55.56%
收藏
已结贴  问题点数:10 回复次数:3 
c++友原问题。。。
#include<iostream>
using namespace std;
class Time
{
    friend ostream &operator<<(ostream &output,Time &t);
    friend istream  &operator>>(istream &input,Time &t);
private:
    int hour;
    int minute;
    int second;
};
ostream &operator<<(ostream &output,Time &t)
{
    output<<t.hour<<"/"<<t.minute<<"/"<<t.second;
    return output;
}
istream &operator>>(istream &input,Time &t)
{
    input.ignore();
    input>>t.hour;
    input.ignore(2);
    input>>t.minute;
    input.ignore();
    input>>t.second;
    return input;
}
int main()
{
    Time t;
    cin>>t;
    cout<<t;
}
   
这个代码说是没有访问权限?、、
请大虾指教一二。。。我实在不不明白了
搜索更多相关主题的帖子: friend return include private 
2012-10-02 20:36
陈便往
Rank: 2
等 级:论坛游民
帖 子:61
专家分:32
注 册:2011-9-21
收藏
得分:0 
juJUjuju据说在vs上能运行
2012-10-02 21:26
lz1091914999
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:四川
等 级:贵宾
威 望:37
帖 子:2011
专家分:5959
注 册:2010-11-1
收藏
得分:7 
VC6的原因,很老的编译器了,该换了,解决办法:
1、更新到VC++ sp6
2、把:
    include <iostream>
    using namespace std;
   改为:
    #include <iostream.h>

My life is brilliant
2012-10-02 23:13
陈便往
Rank: 2
等 级:论坛游民
帖 子:61
专家分:32
注 册:2011-9-21
收藏
得分:0 
c++不是支持流云算吗?改成头文件是为什么?
2012-10-03 22:26
快速回复:c++友原问题。。。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014558 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved