Help on definitions

This is a discussion on Help on definitions within the C++ Programming forums, part of the General Programming Boards category; I need help in the following definitions: ptr, foo....

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    7

    Help on definitions

    I need help in the following definitions: ptr, foo.

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Personally, I thinks its all to easy to get carried away with over-decoration of variable names.
    ... What he said.

    Variable names along the lines of m_sprgszName are just painful.

    One other fairly common practice is to have pointer typedefs. If you hade a linked list, and dealt mostly with node*s instead of nodes, you might have:

    typedef node* node_ptr;
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    foo is just a common arbitrary name for something, often a function. It is commonly used in combination with another name called bar:

    Code:
    #include <iostream>
    using namespace std;
    
    void foo()
    {
      cout << "Hello" ;
    }
    
    void bar()
    {
      cout << " World!" << endl;
    }
    
    int main()
    {
       foo();
       bar();
       return 0;
    }
    I suppose you could use somehting like jumpin and jehosephat instead of foo and bar, but foo-bar has some funny historical implications, sorta like "Kilroy was here", so it has just stuck.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 05-24-2009, 02:42 AM
  2. need help with FIFO QueueItem member definitions
    By jackfraust in forum C++ Programming
    Replies: 15
    Last Post: 02-26-2009, 05:48 PM
  3. Replies: 7
    Last Post: 11-17-2008, 12:00 PM
  4. Replies: 1
    Last Post: 05-05-2006, 11:46 PM
  5. help writing function definitions
    By jlmac2001 in forum C++ Programming
    Replies: 2
    Last Post: 04-10-2003, 09:44 PM

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