List x; and List x();?

Discussion in 'C' started by heena.mca, Mar 13, 2008.

  1. heena.mca

    heena.mca New Member

    Joined:
    Feb 14, 2008
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Is there any difference between List x; and List x();?
     
  2. asadullah.ansari

    asadullah.ansari TechCake

    Joined:
    Jan 9, 2008
    Messages:
    356
    Likes Received:
    14
    Trophy Points:
    0
    Occupation:
    Developer
    Location:
    NOIDA
    if List is class
    then meaning of List x is that x is object of class List.
    meaning of List x() is that x is a function which returns a object type List.
     
  3. ismail.tech21

    ismail.tech21 New Member

    Joined:
    Feb 14, 2008
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    you can see the following example
    Code:
    void f()
     {
       List x;     // Local object named x (of class List)
       ...
     } 
    
    

    Code:
    
     void g()
     {
       List x();   // Function named x (that returns a List)
       ...
     }
    
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice