标题:stack overflow 我已经自己调试了栈的空间大小还是不行啊怎么办?
只看楼主
一个人管他呢
Rank: 2
等 级:论坛游民
帖 子:3
专家分:10
注 册:2016-5-5
结帖率:100%
已结贴  问题点数: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
等 级:版主
威 望:507
帖 子:8890
专家分:53117
注 册: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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-464422-1-1.html




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

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