help me ! some declaration error

This is a discussion on help me ! some declaration error within the C++ Programming forums, part of the General Programming Boards category; i got this error ISO C++ forbids declaration of 'VolymCube' with no type .. i think i wrote exactly same ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    6

    help me ! some declaration error

    i got this error ISO C++ forbids declaration of 'VolymCube' with no type .. i think i wrote exactly same as the book ( C++ for beginner in 3 weeks) but the program dont work here is the code.

    Code:
    #include <iostream>
    
    int VolymCube ( int lenght, int width = 25, int height = 1);
    using namespace std;
    int main ()
    
    {
        
        int lenght = 100;
        int width = 50;
        int height = 25;
        int volym;
        
        volym = VolymCube( lenght,width,height);
        cout << " Volym first round is " << volym << "\n";
        
        
        volym = VolymCube( lenght,width);
        cout << " Volym second round is " << volym << "\n";
        
        
        volym = VolymCube( lenght);
        cout << " Volym third round is " << volym << "\n";
        
        int z;
        cin >> z;
        return 0;
        
    }
    
    VolymCube (int lenght, int width, int height)
    
    {
              return ( lenght * width * height);
              
              }

  2. #2
    Registered User
    Join Date
    Nov 2010
    Posts
    10
    what is the error you get?

  3. #3
    The larch
    Join Date
    May 2006
    Posts
    3,573
    So take a look at the line where the error is and see how it differs from how you have declared the function earlier?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,679
    You're declared the function as returning int. When defining (implementing) the function you have not specified the return type.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Sunshine, and read this, this, and this before posting again.

  5. #5
    Registered User
    Join Date
    Nov 2010
    Posts
    6
    its working now thax for got to put int infront of VolymCube

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling Libraries in C
    By TheOriginalGame in forum C Programming
    Replies: 3
    Last Post: 08-15-2010, 12:19 PM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 09:26 AM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 09:11 AM
  5. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM

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