Void

Discussion in 'Programming' started by faraz01, Feb 25, 2010.

  1. #1
    What is the basic role of VOID in Programming?
     
    faraz01, Feb 25, 2010 IP
  2. tenev

    tenev Active Member

    Messages:
    322
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    95
    #2
    example with C++ -
    void YourFunctionName()
    {}

    in php
    function YourFunctionName()
    {}
     
    tenev, Feb 25, 2010 IP
  3. n3r0x

    n3r0x Well-Known Member

    Messages:
    257
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    120
    #3
    Void is a "function" that does something but never returns a value.. So you have no way of knowing if it was a success or not..
     
    n3r0x, Feb 25, 2010 IP
  4. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Consider following function...

    void functionName (void) {
      
        // code here
    
    }
    Code (markup):
    The void before function name says the function has no return type. The one within brackets says the function doesn't accept any parameters.

    Check in comparison to the following,

    This function has a return value, still accept no parameters.

    int functionName (void) {
    
         if (success){
             return 1;
         }
         else{
             return 0;
         }
    }
    Code (markup):



    This one accepts a single parameter but has no return type.

    void functionName ( int *a) {
    
          (*a)++;
    }
    Code (markup):
     
    Last edited: Feb 25, 2010
    NeoCambell, Feb 25, 2010 IP
  5. faraz01

    faraz01 Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    MY concept is clear now thank u so much people for your sharing.:)
     
    faraz01, Feb 26, 2010 IP