curiosity question.

This is a discussion on curiosity question. within the C++ Programming forums, part of the General Programming Boards category; I didnt think you could declare a function, say void idle(float); in one source file, and then define it in ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    411

    curiosity question.

    I didnt think you could declare a function, say

    void idle(float);

    in one source file, and then define it in a different file?
    It seems to be working fine, I just didnt think it was supposed to?

    Im useing MSVC

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    > I just didnt think it was supposed to?

    Why not? If you had to define the function in each compiled file you'd get re-definition errors. Functions can be seen anywhere in the translation unit by default and can be used in any file where they are declared. If you want to 'hide' a function in a file you can do -

    static void idle(float){//do stuff}

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    Usually when a function idle is defined in file A, then in file B it is referred to as:

    extern void idle (float);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 01:52 PM
  2. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM
  3. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM

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