Overloaded Member Function

I am getting the following error:
error C2511: 'double Distance::MtoE(double) const' : overloaded member function not found in 'Distance'

I am new at this, and not sure what I need to do to correct the error message... Here is a snippet of my 'Distance' Class:
public:
      //constructors -
      Distance ();  //default constructor
      Distance (long millimeter);
      Distance (long meter, long centimeter, long millimeter);
      Distance (int feet, int inches);
      Distance (double miles);

      //Access Functions
      double GetDistance () const;  // distance storing converted to mm
      void SetDistance (double mm); // "set the stored distance accordingly"?

      //Conversion functions
      double MtoE () const;

Then here is where the error is pointing me to....
double Distance::MtoE (double value) const {
       double value = 0;
      // converting given value to millimeters
      (value * MTF) / 1000; // MTF is defined in the header.
}


Any advice / explanation would be very much appreciated.
gndcdospsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Infinity08Commented:
       double MtoE () const;

does not correspond to :

        double Distance::MtoE (double value) const

They need to be the same ... do you need a double argument or not ? If so, then put this inside the class :

        double MtoE (double value) const;

if not, then modify the implementation like this :

        double Distance::MtoE () const {
            // the code ...
        }
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ravenplCommented:
from class prototype
Distance (double miles);
from implementation
double Distance::MtoE (double value) const

either add const in class declaration, or strip the const from method definition (implementation)
0
ravenplCommented:
I'm sorry - ignore my comment - lloks like I'm too tired now.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

evilrixSenior Software Engineer (Avast)Commented:
double Distance::MtoE (double value) const {
       double value = 0;
      // converting given value to millimeters
      (value * MTF) / 1000; // MTF is defined in the header.
}

This function is prototyped to return a double... it returns nothing. This will also cause you a compiler error. Also, it takes value as a parameter and then sets it to 0 and then uses it in a multiplication (anything multiplied by 0 is 0!) and then divides 0 by 1000 -- also 0!

You seem to have a few inconsistencies to sort out here :)
0
evilrixSenior Software Engineer (Avast)Commented:
>> Also, it takes value as a parameter and then sets it to 0
Strike that, I'll re-state: it takes value as a parameter and also declares a local variable called value, which is set to 0.
0
ravenplCommented:
Declaring local variable with same name as parameter shadows the param - the parameter is inaccessible then. Usually compiler casts a warning.
But I guess Infinity08 said all required here. There's inconsistency between declaration and definition...
0
Infinity08Commented:
>> But I guess Infinity08 said all required here.

All required to solve the compiler error mentioned in the question ;)

But evilrix is right that there are further problems ... We can fix them one at a time though ... It's just waiting for gndcdosps to get back to us now heh :)
0
gndcdospsAuthor Commented:
Sorry for the delayed response... Can you give me a little bit to look over your comments.  I am working from home today, and have to take care of a few things before I can look at this, again.  It may be a couple of hours....
0
Infinity08Commented:
No problem ... Take your time. And remember : in case there are further problems, feel free to ask about them. In that case, it would also be good to post a bit more code ...
0
evilrixSenior Software Engineer (Avast)Commented:
>> Declaring local variable with same name as parameter shadows the param - the parameter is inaccessible then. Usually compiler casts a warning
It'll given a error, since it's a redefinition of a variable within the same scope.

>> There's inconsistency between declaration and definition...
Yes there is but there are also other issues that will cause problems when this is resolved.
0
gndcdospsAuthor Commented:
I am sorry I did not get back to everyone sooner.  I am back to trying to figure this out, but believe I will be doing another post.  

Thanks as always for you time, help, and expertise!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.