complex object declaration

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • babu198649
    New Member
    • Sep 2007
    • 22

    #1

    complex object declaration

    hi
    i am a new bie to c++ and found that function has been declared in place of object.
    (ie)
    class_name object_name; //normal declaration

    class _name object_name( ); //it works but what does it mean plese help


    Thanks in advance
  • letmetry
    New Member
    • Sep 2007
    • 9

    #2
    Originally posted by babu198649
    hi
    i am a new bie to c++ and found that function has been declared in place of object.
    (ie)
    class_name object_name; //normal declaration

    class _name object_name( ); //it works but what does it mean plese help


    Thanks in advance
    class _name object_name( );

    The above declarations is used to call the class "Constructe r" while declaring the object. Get familiar with the concept of constructors to understand better..

    Comment

    • babu198649
      New Member
      • Sep 2007
      • 22

      #3
      thanks for u r reply . i know about constructors and the object_name() was not the same name as a classname and i am sure that it was not a constructor.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        This is defining a class_name object called object_name:
        Originally posted by babu198649
        class_name object_name; //normal declaration
        This is a function prototype of a function named object_name that takes no arguments ans returns a class_name object:
        Originally posted by babu198649
        class _name object_name( ); //it works but what does it mean plese help

        Comment

        • babu198649
          New Member
          • Sep 2007
          • 22

          #5
          thanks

          ie. a function returning the object of type class_name. right.

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            Yes. That's correct.

            Comment

            Working...