prolem in method signature

This is a discussion on prolem in method signature within the C++ Programming forums, part of the General Programming Boards category; What is wrong with this line of code? Code: void retrieve(unsigned int position, char output[20]) throw(std::out_of_range); H:\code_blocks_workspace\src\..\include\LinkedList .h|13|error: expected type-specifier| ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Location
    Vancouver
    Posts
    108

    prolem in method signature

    What is wrong with this line of code?

    Code:
    void retrieve(unsigned int position, char output[20]) throw(std::out_of_range);
    H:\code_blocks_workspace\src\..\include\LinkedList .h|13|error: expected type-specifier|
    H:\code_blocks_workspace\src\..\include\LinkedList .h|13|error: expected ')'|
    H:\code_blocks_workspace\src\..\include\LinkedList .h|13|error: expected ';'|
    H:\code_blocks_workspace\src\LinkedList.cpp|100|er ror: expected type-specifier|
    H:\code_blocks_workspace\src\LinkedList.cpp|100|er ror: expected ')'|
    H:\code_blocks_workspace\src\LinkedList.cpp|100|er ror: expected initializer|
    ||=== Build finished: 6 errors, 0 warnings ===|

  2. #2
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    671
    I think nothing.

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    120
    Shouldn't it just be char output[] ?

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    2,372
    C Programmer with guess
    Did you have "#include <stdexcept>" in the file below the line with error.

    Tim S.

  5. #5
    Registered User
    Join Date
    Apr 2010
    Location
    Vancouver
    Posts
    108
    Quote Originally Posted by stahta01 View Post
    C Programmer with guess
    Did you have "#include <stdexcept>" in the file below the line with error.

    Tim S.
    You know, that was a really good guess.
    One thing I'm curious about is should I include things in the .h (header) or .cpp (implemntation) file?
    Last edited by c_weed; 12-09-2010 at 03:44 PM.

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by c_weed View Post
    You know, that was a really good guess.
    One thing I'm curious about is should I include things in the .h (header) or .cpp (implemntation) file?
    You should #include the header in whatever file uses elements from that header.

  7. #7
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    671
    Quote Originally Posted by c_weed View Post
    You know, that was a really good guess.
    One thing I'm curious about is should I include things in the .h (header) or .cpp (implemntation) file?
    You should avoid including in header files as much as possible (it makes compilation process longer). Use forward declarations wherever possible. You should also have (a) precompiled header(s) with commonly used headers that does not change often (like external libraries' headers, STL, etc). Most of my inclusions are in .cpp files.
    Last edited by kmdv; 12-10-2010 at 05:17 AM.

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,169
    Throwing declarations are rarely useful, as few, if any, compilers actually heed them. Microsoft's compiler is actually known not to even implement this and gives a warning. They're usually only useful as documentation--that is, understanding what a function may throw.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Packet Container Class
    By ChaoticXSinZ in forum C++ Programming
    Replies: 2
    Last Post: 11-01-2010, 12:07 AM
  2. on method pointers and inheritance
    By BrownB in forum C++ Programming
    Replies: 2
    Last Post: 03-02-2009, 06:50 PM
  3. C# method
    By siten0308 in forum C# Programming
    Replies: 6
    Last Post: 07-15-2008, 07:01 AM
  4. Overriding a method in C
    By DavidDobson in forum C Programming
    Replies: 1
    Last Post: 07-05-2008, 07:51 AM
  5. Callback function as class method
    By schifers in forum Windows Programming
    Replies: 39
    Last Post: 05-19-2008, 03:02 PM

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