1.11M Members

[Error] reference to 'distanc

 
0
 

compiler is showing this error but I don't know where I went wrong with my simple structure program.

#include <iostream>
#include <conio.h>
using namespace std;
#include<iostream>
#include<conio.h>
using namespace std;
struct distance                //structure 
{
    int foot;
    float inches;
}; 
int main()
{

distance a,b;
distance c={3,6.34};
cout<<"Enter feet and inches of distance a"<<endl;
cin>>a.foot<<a.inches<<endl;
b.inches=c.inches+a.inches;
b.foot=c.foot+a.foott;
cout<<"distance a: "<<a.foott<<a.inches<<endl;
cout<<"distance b: "<<b.foott<<b.inches<<endl;
cout<<"distance c: "<<c.foott<<c.inches<<endl;
getche();
return 0;
}
 
0
 

Plese post the entire compiler error output. However, line 18 is wrong. Instead of cin>>a.foot<<a.inches<<endl; try cin>>a.foot>>a.inches;

 
0
 

distance is the name of a function in the standard library, use it for something else at your own risk.

Check your spelling and choice of operators as well.

 
0
 

it stiil says [Error] reference to 'distance' is ambiguous even after I've corrected the 18th line..

 
0
 

Like was mentioned you've used a keyword as a custom type. Line 18 has nothing to do with that error. Change the name of your struct.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article