paradise_human
جمعه 17 اردیبهشت 1389, 12:43 عصر
سلام.
من این برنامه رو با کامپایلر vs2008 بدون مشکل اجرا کردم ولی توی کامپایلر vs2010 ارور میده!
ارورشم اینه که پیش تعریف تابع sqrt با خود تابع sqrt تداخل داره !
این برنامه :
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
using namespace std;
class Point
{
int x;
int y;
public:
Point(int,int);
void print();
void symmetry();
void distance_from_start();
void distance_2point(int,int,Point);
};
Point::Point(int a=0,int b=0)
{x=a;y=b;}
void Point::symmetry()
{
int c;
c=x;
x=y;
y=c;
}
void Point::print()
{
cout<<"Your first point is:"<<"("<<x<<","<<y<<")"<<endl;
cout<<"and your distance from start is : "<<endl;
distance_from_start();
cout<<endl;
}
void Point::distance_from_start()
{
int z;
double sqrt(double);
z=(x*x)+(y*y);
cout<<sqrt(z);
}
void Point::distance_2point(int c,int d,Point p)
{
int z;
z=((c-x)*(c-x))+((d-y)*(d-y));
double sqrt(double);
cout<<sqrt(z);
}
void main()
{
int a,b,c,d;
cout<<"Please enter your first point: "<<endl;
cout<<"X:";
cin>>a;
cout<<"Y:";
cin>>b;
system("cls");
Point p(a,b);
cout<<"Do you want to reverse it ? (y/n) "<<endl;
switch(getch())
{
case 'y':
p.symmetry();
break;
case 'n':
break;
}
system("cls");
p.print();
getch();
system("cls");
cout<<"Do you want to calculate distance from this point to another point ? (y/n) :"<<endl;
switch(getch())
{
case 'y':
system("cls");
cout<<"Please enter your second point : "<<endl;
cout<<"X:";
cin>>c;
cout<<"Y:";
cin>>d;
system("cls");
break;
case 'n':
exit(0);
break;
}
cout<<"Distance from two point is:"<<endl;
p.distance_2point(c,d,p);
cout<<endl;
}
اینم ارورش :
function declaration conflicts with 'sqrt' introduced by using-declaration
چطور مشکلشو حل کنم ؟
من این برنامه رو با کامپایلر vs2008 بدون مشکل اجرا کردم ولی توی کامپایلر vs2010 ارور میده!
ارورشم اینه که پیش تعریف تابع sqrt با خود تابع sqrt تداخل داره !
این برنامه :
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
using namespace std;
class Point
{
int x;
int y;
public:
Point(int,int);
void print();
void symmetry();
void distance_from_start();
void distance_2point(int,int,Point);
};
Point::Point(int a=0,int b=0)
{x=a;y=b;}
void Point::symmetry()
{
int c;
c=x;
x=y;
y=c;
}
void Point::print()
{
cout<<"Your first point is:"<<"("<<x<<","<<y<<")"<<endl;
cout<<"and your distance from start is : "<<endl;
distance_from_start();
cout<<endl;
}
void Point::distance_from_start()
{
int z;
double sqrt(double);
z=(x*x)+(y*y);
cout<<sqrt(z);
}
void Point::distance_2point(int c,int d,Point p)
{
int z;
z=((c-x)*(c-x))+((d-y)*(d-y));
double sqrt(double);
cout<<sqrt(z);
}
void main()
{
int a,b,c,d;
cout<<"Please enter your first point: "<<endl;
cout<<"X:";
cin>>a;
cout<<"Y:";
cin>>b;
system("cls");
Point p(a,b);
cout<<"Do you want to reverse it ? (y/n) "<<endl;
switch(getch())
{
case 'y':
p.symmetry();
break;
case 'n':
break;
}
system("cls");
p.print();
getch();
system("cls");
cout<<"Do you want to calculate distance from this point to another point ? (y/n) :"<<endl;
switch(getch())
{
case 'y':
system("cls");
cout<<"Please enter your second point : "<<endl;
cout<<"X:";
cin>>c;
cout<<"Y:";
cin>>d;
system("cls");
break;
case 'n':
exit(0);
break;
}
cout<<"Distance from two point is:"<<endl;
p.distance_2point(c,d,p);
cout<<endl;
}
اینم ارورش :
function declaration conflicts with 'sqrt' introduced by using-declaration
چطور مشکلشو حل کنم ؟