Thread: Simple doubt on declaration

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    50

    Simple doubt on declaration

    Can anyone plz give an example for this statement " a function can have many declaration but only one definition"?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Saurabh Mehta
    Can anyone plz give an example for this statement " a function can have many declaration but only one definition"?
    What is a function declaration and what is a function definition? Give examples.

    Construct two programs, each of which is to have a main function that calls a function named foo: one program declares foo many times but defines it exactly once; the other defines foo multiple times. Compile both programs. What do you observe?
    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
    Registered User
    Join Date
    Nov 2012
    Posts
    50
    function foo is already defined error
    Can you plz give example on this notion?

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by Saurabh Mehta View Post
    Can you plz give example on this notion?
    laserlight already has. Read her post carefully, and follow the advice on constructing two programs.
    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, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. very simple doubt
    By scofield in forum C Programming
    Replies: 2
    Last Post: 02-04-2012, 08:52 AM
  2. Array declaration doubt
    By finalsayan in forum C Programming
    Replies: 8
    Last Post: 03-29-2010, 09:56 AM
  3. A very simple doubt
    By afser in forum C Programming
    Replies: 7
    Last Post: 10-26-2008, 02:30 PM
  4. a simple doubt!
    By chottachatri in forum C Programming
    Replies: 7
    Last Post: 10-10-2008, 01:42 PM
  5. a simple doubt in graphics
    By nikhil_trichy in forum Game Programming
    Replies: 7
    Last Post: 02-02-2006, 10:01 PM