Confusing errors in simple overload program...help?

edited June 2003 in Science & Tech
I am having a bit of trouble with this C++ program and cursed ANSI C++ (oh why did I want to stray from thee, faithful microsoft? lol). I cant figure out why the hell I am getting this error (and neither can L0ki, which majorly surprises me) in my program...Try to compile it for yourself to see the error, there are way to many to list here and they are all way to vague...
Heres the code, its an attempt at screwing with overloads:
// overdist.cpp
// demonstrates overloading
#include <iostream>
using namespace std;

struct distance
int feet;
float inches;

void engldisp (distance);
void engldisp (float);

int main()
distance d1; //distance of type distance
float d2; //distance of float
//get d1 from user
cout<<"Enter feet: "; cin>>d1.feet;
cout<<"Enter inches: "; cin>>d1.inches;
//get d2 from user
cout<<"Enter entire distance 2 in inches: "; cin>>d2;
cout<<"\nd1 = ";
cout<<"\nd2 = ";
return 0;
void engldisp(distance dd) //for type distance
void engldisp(float dd) //for type float
int feet = int(dd)/12;
float inches = dd - float(feet)*12;

Any suggestions?


  • MeltdownMeltdown NW GA
    edited June 2003
    I turned the last 3 distance into ::distance and it compiled fine. Since my c++ knowledge is poor at best, I used my buddy google to come to that fix.

    MSDN had some info about error c2872.
    I guess the compiler didn't know if you wanted ::distance or std::distance(wild guess).

    Since I'm not a C++ master, maybe someone who is can chime in and say if I'm way off base here.
  • edited June 2003
    thx, it works.
Sign In or Register to comment.