标题:求助:error C2550: 'Ponit' : constructor initializer lists are only al ...
取消只看楼主
落叶风
Rank: 2
等 级:论坛游民
帖 子:22
专家分:53
注 册:2011-6-22
结帖率:100%
已结贴  问题点数:10 回复次数:1 
求助:error C2550: 'Ponit' : constructor initializer lists are only allowed on cons
程序代码:
//类定义
class Point
{
public:
    Point(int x=0,int y=0):x(x),y(y) {}
    Ponit(const Point &p);
    ~Point() {count--;}
    int getx()  const {return x;}
    int gety()  const {return y;}
    static void showcount();
private:
    int x,y;
    static int count;
};

//类实现
#include"Point.h"
#include<iostream>
using namespace std;

int Point::count=0;
Point::Ponit(const Point &p):x(p.x),y(p.y)
{
    count++;
}

void Point::showcount()
{
    cout<<"Objiect count="<<count<<endl;
}

//主函数
#include"Point.h"
#include<iostream>
using namespace std;


int main()
{
    Point a(4,5);
    cout<<"Point A:"<<a.getx()<<","<<a.gety();
    Point::showcount();

    Point b(a);
    cout<<"Point B:"<<b.getx()<<","<<b.gety();
    Point::showcount();

    return 0;
}
搜索更多相关主题的帖子: only count 
2012-03-15 09:53
落叶风
Rank: 2
等 级:论坛游民
帖 子:22
专家分:53
注 册:2011-6-22
得分:0 
我找了半天没看见。。。谢谢
2012-03-15 12:10



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




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

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