| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3536 人关注过本帖, 1 人收藏
标题:stack overflow 我已经自己调试了栈的空间大小还是不行啊怎么办?
只看楼主 加入收藏
一个人管他呢
Rank: 2
等 级:论坛游民
帖 子:3
专家分:10
注 册:2016-5-5
结帖率:100%
收藏(1)
已结贴  问题点数:20 回复次数:2 
stack overflow 我已经自己调试了栈的空间大小还是不行啊怎么办?
#include<iostream.h>
class point
{
protected:
    int x;
    int y;
public:
    point(int c,int k):x(c),y(k){}
    friend ostream & operator << (ostream & output,point & p);
    friend istream & operator >> (istream & input ,point & p);
};
istream & operator >> (istream & input,point & p)
{
    char a;
    input>>a>>p.x>>a>>p.y>>a;
    return input;
}
ostream & operator << (ostream & output,point & p)
{
    cout<<"the point is :"<< "(" << p.x << "," << p.y << ")"<<endl;
    return output;
}
class circle:public point
{
private:
    int r;
public:
    circle(int x,int y,int r1):point(x,y){ r = r1;}
    friend ostream & operator << (ostream & output,circle & c);
};
/**/ostream & operator << (ostream & output,circle & c)
{   

    cout<<c;
    return output;
}
int main()
{
    circle c1(0,1,2);
    cout<<c1;
    return 0;
}
搜索更多相关主题的帖子: include public friend return 空间 
2016-05-05 14:23
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9025
专家分:54030
注 册:2011-1-18
收藏
得分:14 
程序代码:
#include <iostream>
#include <iomanip>

class point
{
public:
    point( int x, int y ) : x_(x), y_(y)
    {
    }
protected:
    int x_;
    int y_;

    friend std::istream& operator>>( std::istream& input, point& pt );
    friend std::ostream& operator<<( std::ostream& output, const point& pt );
};

std::istream& operator>>( std::istream& input, point& pt )
{
    char a, b, c;
    int x, y;
    input >> std::ws >> a >> x >> std::ws >> b >> y >> std::ws >> c;
    if( input )
    {
        pt.x_ = x;
        pt.y_ = y;
    }
    return input;
}
std::ostream& operator<<( std::ostream& output, const point& pt )
{
    return output << '(' << pt.x_ << ',' << pt.y_ << ')';
}

class circle : public point
{
public:
    circle( int x, int y, int r ) : point(x,y), r_(r)
    {
    }
protected:
    int r_;

    friend std::ostream& operator<<( std::ostream& output, const circle& cc );
};

std::ostream& operator<<( std::ostream& output, const circle& cc )
{
    return output << '[' << (const point&)cc << ',' << cc.r_ << ']';
}

using namespace std;

int main( void )
{
    circle c( 0, 1 ,2 );
    cout << "the circle is " << c << endl;

    return 0;
}
2016-05-05 14:56
一个人管他呢
Rank: 2
等 级:论坛游民
帖 子:3
专家分:10
注 册:2016-5-5
收藏
得分:0 
看不懂
2016-05-06 10:41
快速回复:stack overflow 我已经自己调试了栈的空间大小还是不行啊怎么办?
数据加载中...
 
   



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

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