|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include "pt.h"
#include <iostream>
#include <math.h>
using namespace std;
pt::pt(int x, int y)
{
(*this).x = x;
(*this).y = y;
}
void pt::afficher()
{
cout << "(" << (*this).x << "," << (*this).y << ")";
}
void pt::deplacer(int dx, int dy)
{
(*this).x += dx;
(*this).y += dy;
}
void pt::saisir()
{
cout << "Entrer la valeur de x: ";
cin >> (*this).x;
cout << "Entrer la valeur de y: ";
cin >> (*this).y;
}
// Le cosntructeur est une fonction qui ne cr茅e pas l'objet mais qui accompagne la cr茅ation de fa?on 脿 ce que l'objet soit pr锚t 脿 l'utilisation.
float pt::distance(pt & p)
{
float dx=((*this).x-p.x);
float dy=((*this).y-p.y);
return (sqrtf(dx*dx+dy*dy));
}
void pt::deplacer(pt &p)
{
(*this).x += p.x;
(*this).y += p.y;
}
bool pt::identique(pt & p)
{
float d;
d=(*this).distance(p);
if(d<0.01) return true;
else return false;
}
// Q4
pt::pt(const pt &p)
{
(*this).x=p.x;
(*this).y=p.y;
}
// pour Q7
int pt::getx()
{
return((*this).x);
}
int pt::gety()
{
return((*this).y);
}
void pt::putx(int x)
{
(*this).x=x;
}
void pt::puty(int y)
{
(*this).y=y;
}
在法国留学 这是老师给的答案 我怎么改都没有用,他说可能是我编译器的问题,我用的dev-c
求大神解释一下呀
重新建立一个工程,建立的时候选 控制台应用程序
你现在的是 win32窗口程序,入口是WinMain
控制台应用程序的入口是 main
|
-
|