在开发中获得跟随错误但是在borland c上工作 - “引用距离是不明确的” [英] getting following error in dev c but working on borland c - "reference to distance is ambigious"
本文介绍了在开发中获得跟随错误但是在borland c上工作 - “引用距离是不明确的”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include<iostream>
#include<conio.h>
using namespace std;
class distance
{
int meter;
int cmeter;
public:
void inputdata()
{
cout<<"Enter the distance(in meter and centimeter): ";
cin>>meter>>cmeter;
}
void display();
}y;
void distance::display()
{
meter=meter+cmeter/100;
cout<<"\ncmeter : "<<cmeter;
cmeter=cmeter%100;
cout<<"\n the distance entered is : ";
cout<<meter<<"M"<<cmeter<<"CM";
}
int main()
{
distance x;
cout<<"\n object x \n";
x.inputdata();
x.display();
cout<<"\nobject y \n";
y.inputdata();
y.display();
getch();
return 0;
}
推荐答案
您班级的名称,距离
冲突与C ++
标准库中使用的名称相同。为了避免这样的错误,您有几种选择:
- 更改班级名称(例如
距离
会没事) 。- 使用命名空间std; 行删除
并使用
std ::
限定每个标识符标准库。- 在命名空间中包含
距离
类。
The name of your class,distance
clashes with the same name used in theC++
standard library. To avoid such an error you have several alternatives:
- Change the name of your class (e.g.
Distance
would be fine).- Remove the
using namespace std;
line and qualify withstd::
every identifier of the standard library.- Enclose your
distance
class in a namespace.
这篇关于在开发中获得跟随错误但是在borland c上工作 - “引用距离是不明确的”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文