| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 568 人关注过本帖
标题:请问一个程序在VC6.0上可以运行,但在visual studio2010上就不能运行这是为 ...
只看楼主 加入收藏
zpjm
Rank: 2
等 级:论坛游民
帖 子:36
专家分:21
注 册:2011-3-2
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:3 
请问一个程序在VC6.0上可以运行,但在visual studio2010上就不能运行这是为什么????
以下程序vc6.0正常运行,在visual studio2010上说重载有问题,请指正!!!!
#include <iostream>
#include <cmath>
using namespace std;

class Point
{
public:
    Point(){x=0;y=0;}
    Point(int X,int Y);
    int GetX(){return this->x;}
    int GetY(){return this->y;}
    double Distance() ;

private:
    int x,y;
};

Point::Point(int X,int Y){x=X;y=Y;}

double Point::Distance() {double dis; dis=sqrt(x*x+y*y); return dis;}

void main()
{
        Point p0;

    cout<<p0.GetX()<<","<<p0.GetY()<<endl;
    cout<<p0.Distance()<<endl;
   
   
    int m,n;
    cin>>m>>n;
    Point p1(m,n);

    cout<<p1.GetX()<<","<<p1.GetY()<<endl;
    cout<<p1.Distance()<<endl;
   
}

搜索更多相关主题的帖子: return   
搜索更多相关主题的帖子: return 
2011-04-08 14:13
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
收藏
得分:20 
#include <iostream>
#include <cmath>
using namespace std;

class Point
{
public:
    Point(){x=0;y=0;}
    Point(int X,int Y);
    int GetX(){return this.x;}
    int GetY(){return this.y;}
    double Distance() ;

private:
    int x,y;
};

Point::Point(int X,int Y){x=X;y=Y;}

double Point::Distance() {double dis; dis=sqrt(x*x+y*y); return dis;}

void main()
{
        Point p0=new Point();

    cout<<p0.GetX()<<","<<p0.GetY()<<endl;
    cout<<p0.Distance()<<endl;
   
   
    int m,n;
    cin>>m>>n;
    Point p1=new Point(m,n);

    cout<<p1.GetX()<<","<<p1.GetY()<<endl;
    cout<<p1.Distance()<<endl;
   
}


   唯实惟新 至诚致志
2011-04-08 14:53
zpjm
Rank: 2
等 级:论坛游民
帖 子:36
专家分:21
注 册:2011-3-2
收藏
得分:0 
回复 2楼 qq1023569223
原因是什么?
2011-04-09 17:29
w_yfei
Rank: 1
等 级:新手上路
帖 子:4
专家分:5
注 册:2012-10-15
收藏
得分:0 
奇怪,没有看懂。
2012-10-15 09:29
快速回复:请问一个程序在VC6.0上可以运行,但在visual studio2010上就不能运行这 ...
数据加载中...
 
   



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

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