What's wrong?

This is a discussion on What's wrong? within the C++ Programming forums, part of the General Programming Boards category; what's wrong? It keeps coming up with to few arguments to function ( its in a header) Code: inline float ...

  1. #1
    Registered User bobbinator's Avatar
    Join Date
    Jul 2009
    Posts
    29

    Unhappy What's wrong?

    what's wrong?
    It keeps coming up with to few arguments to function ( its in a header)


    Code:
    inline float tang(string A_O_Aj, float angle, float opposite, float adjacent)
    {
        float x = 0;
    
        if(A_O_Aj == "A")
        {
            x = opposite / adjacent;
            x = atan(x);
            x = x * (180 / 3.141592);
            return x;
        }
    
        if(A_O_Aj == "O")
        {
            x = angle * (3.141592 / 180);
            return x;
        }
    
        if(A_O_Aj == "Aj")
        {
            x = opposite / (tan(angle * (3.141592 / 180)));
            return x;
        }
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,616
    The only thing wrong at compile time is the lack of a return statement:
    Code:
    #include <string>
    #include <cmath>
    
    using namespace std;
    
    inline float tang(string A_O_Aj, float angle, float opposite, float adjacent)
    {
        float x = 0;
    
        if(A_O_Aj == "A")
        {
            x = opposite / adjacent;
            x = atan(x);
            x = x * (180 / 3.141592);
            return x;
        }
    
        if(A_O_Aj == "O")
        {
            x = angle * (3.141592 / 180);
            return x;
        }
    
        if(A_O_Aj == "Aj")
        {
            x = opposite / (tan(angle * (3.141592 / 180)));
            return x;
        }
    }
    
    int main()
    {
        tang("A", 1, 2, 3);
    }
    The compiler output:
    Code:
    test.cpp: In function 'float tang(std::string, float, float, float)':
    test.cpp:29: warning: control reaches end of non-void function
    If you disagree, post the smallest and simplest program that demonstrates the error, and post the exact error message.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    33,292
    Which line number?
    And which line of your code is that?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User bobbinator's Avatar
    Join Date
    Jul 2009
    Posts
    29
    never mind, once again im being a retard!
    I did not write the function write, sorrry!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 03:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 09:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 12:40 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 11:01 AM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 01:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21