Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2004
    Location
    Wisconsin
    Posts
    1,424

    'operator <<' is ambiguous Error

    Ok, well I am doing this litte temperature conversion exercise, and I am getting an odd error. From what I see on MSDN and the web, it has to do with identifier overloading. I don't really know what this is, but I don't think I'm doing it! at least not on purpose...

    PHP Code:
    #include <iostream>

    using namespace std;

    double tempFahrenheit(double currentTemp);
    double tempCelsius(double currentTemp);
    char GetTypeInput(void);
    double GetDegreesInput(void);

    int main()
    {
        
    double temp 0;
        
    char unit ' ';
        
    unit GetTypeInput();
        
    temp GetDegreesInput();
        
    cout << "\nThe current temperature is: ";
        if (
    unit == 'C')
        {
            
    cout << tempFahrenheit(temp) << " degrees Fahrenheit\n";
        }
        else if (
    unit == 'F')
        {
            
    cout << tempCelsuis(temp) << " degrees Celsius\n"
        }
            return 
    0;
    }

    double tempFahrenheit(double currentTemp)
    {
        
    double newTemp 0;
        
    newTemp = (currentTemp 9/5) + 32;
            return 
    newTemp;
    }

    double tempCelsius(double currentTemp)
    {
        
    double newTemp 0;
        
    newTemp = (currentTemp 32) * 5/9;
            return 
    newTemp;
    }

    char GetTypeInput()
    {
    char tmpUnit ' ';
        
    cout << "Please enter the type of temperature you have:";
        
    cin >> tmpUnit;
            return 
    tmpUnit;
    }

    double GetDegreesInput()
    {
        
    double temperature 0;
        
    cout << "Please enter the current temperature:";
        
    cin >> temperature;
            return 
    temperature;

    BTW, it occurs on
    Code:
                  cout << tempCelsuis(temp) << " degrees Celsius\n";
    but not

    Code:
    		cout << tempFahrenheit(temp) << " degrees Fahrenheit\n";
    in the main function.

    I also get a "C3861: 'tempCelsuis': identifier not found, even with argument-dependent lookup" error on the the same line.

    Since the first error occured on the second cout statement, would the error be from the else statement?? I ran it without errors by commenting out the else{} part...

    Well thanks in advance for any posts

  2. #2
    Join Date
    Jan 2004
    Location
    South Pole
    Posts
    1,519
    Silly rabbit..

    CelsIUs, not CelsUIs!

  3. #3
    Join Date
    Aug 2004
    Location
    little rock arkansas
    Posts
    3,482
    lol just a silly spelling mistake...happens to the best of us

  4. #4
    Join Date
    Dec 2004
    Location
    Wisconsin
    Posts
    1,424
    LOL.. sorry for this post! Maybe I should drop my programming classes and take some english

    The thing is, I re-wrote the entire program, and got the same error each time, which means I did the same typo in the same spot both times I thought I copied and pasted the names as well... oh well.. I guess VB has been too easy on me, with it's auto name definition look up spell checker thing Anyway, thanks for the quick posts, and putting up with my stupidity!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •