type, class, object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael

    #1

    type, class, object

    Hi,

    I could understand the difference between class and object. However, I
    could find out a good definiton of type. how to understand the
    relaitonship between type, class, and object? Thanks!

    Michael

  • Victor Bazarov

    #2
    Re: type, class, object

    Michael wrote:
    I could understand the difference between class and object. However, I
    could find out a good definiton of type. how to understand the
    relaitonship between type, class, and object? Thanks!
    'class' is a user-defined type (UDT, a very common TLA in OOP). A type
    is a "kind" of objects, definiting common traits of all *instances* of
    that type ("objects"). Types in C++ are characterized by the name and
    the *definition*. Types in C++ consist of built-in and user-defined.
    The definition of a UDT contains *declarations*, which describe the
    representation and the behaviour of the instances of the UDT. The
    representation and the behaviour of built-in types is defined in the
    Standard.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask


    Comment

    • Michael

      #3
      Re: type, class, object


      Victor Bazarov wrote:
      'class' is a user-defined type (UDT, a very common TLA in OOP). A type
      is a "kind" of objects, definiting common traits of all *instances* of
      that type ("objects"). Types in C++ are characterized by the name and
      the *definition*. Types in C++ consist of built-in and user-defined.
      The definition of a UDT contains *declarations*, which describe the
      representation and the behaviour of the instances of the UDT. The
      representation and the behaviour of built-in types is defined in the
      Standard.
      >
      Could you please take an example for me to better understand it?

      Comment

      • Michael

        #4
        Re: type, class, object


        Victor Bazarov wrote:
        Michael wrote:
        I could understand the difference between class and object. However, I
        could find out a good definiton of type. how to understand the
        relaitonship between type, class, and object? Thanks!
        >
        'class' is a user-defined type (UDT, a very common TLA in OOP). A type
        is a "kind" of objects, definiting common traits of all *instances* of
        that type ("objects"). Types in C++ are characterized by the name and
        the *definition*. Types in C++ consist of built-in and user-defined.
        The definition of a UDT contains *declarations*, which describe the
        representation and the behaviour of the instances of the UDT. The
        representation and the behaviour of built-in types is defined in the
        Standard.
        I would think of type as "Class". Is thar right? There is no difference
        to call "Class" or "Type".

        Comment

        • Pierre Barbier de Reuille

          #5
          Re: type, class, object

          Michael wrote:
          Hi,
          >
          I could understand the difference between class and object. However, I
          could find out a good definiton of type. how to understand the
          relaitonship between type, class, and object? Thanks!
          >
          Michael
          >
          Well, in C++ : the types *include* the classes and objects are instances
          of classes. Some types that are not classes :

          C-like types : int, char, float
          Function pointers types : int (*)(int,int)
          Method pointers types : int (MyClass::*)(in t,int)
          Other pointers type : int*, MyClass*

          Pierre

          Comment

          • Victor Bazarov

            #6
            Re: type, class, object

            Michael wrote:
            Victor Bazarov wrote:
            >Michael wrote:
            >>I could understand the difference between class and object.
            >>However, I could find out a good definiton of type. how to
            >>understand the relaitonship between type, class, and object? Thanks!
            >>
            >'class' is a user-defined type (UDT, a very common TLA in OOP). A
            >type is a "kind" of objects, definiting common traits of all
            >*instances* of that type ("objects"). Types in C++ are
            >characterize d by the name and the *definition*. Types in C++
            >consist of built-in and user-defined. The definition of a UDT
            >contains *declarations*, which describe the representation and the
            >behaviour of the instances of the UDT. The representation and the
            >behaviour of built-in types is defined in the Standard.
            >
            I would think of type as "Class". Is thar right?
            No, in C++ it's vice-versa. Did you actually read what I posted?

            Types consist of built-in and user-defined. "class" is a user-defined
            type. So class is a type. A 'type' is a wider concept than a 'class',
            at least in C++.
            There is no
            difference to call "Class" or "Type".
            In some circumstances there is. You can derive from a class, you
            cannot, generally speaking, derive from a type.

            V
            --
            Please remove capital 'A's when replying by e-mail
            I do not respond to top-posted replies, please don't ask


            Comment

            • Howard

              #7
              Re: type, class, object


              "Michael" <michaelnx@gmai l.comwrote in message
              news:1154540707 .145109.249480@ i3g2000cwc.goog legroups.com...
              >
              Victor Bazarov wrote:
              >Michael wrote:
              I could understand the difference between class and object. However, I
              could find out a good definiton of type. how to understand the
              relaitonship between type, class, and object? Thanks!
              >>
              >'class' is a user-defined type (UDT, a very common TLA in OOP). A type
              >is a "kind" of objects, definiting common traits of all *instances* of
              >that type ("objects"). Types in C++ are characterized by the name and
              >the *definition*. Types in C++ consist of built-in and user-defined.
              >The definition of a UDT contains *declarations*, which describe the
              >representati on and the behaviour of the instances of the UDT. The
              >representati on and the behaviour of built-in types is defined in the
              >Standard.
              >
              I would think of type as "Class". Is thar right? There is no difference
              to call "Class" or "Type".
              >
              Where do you get the word "Class" from? Are you referring to the keyword
              "class", which denotes one kind of user-defined-type? (The other being the
              keyword "struct".)

              The concept of "type" in C++ means, basically, "what kind of thing is
              this?". So, some examples of types are: int, char, and unsigned long.
              These are built-in types, already defined in the language for you.

              If you have a class definition like this:

              class MyClass { /* member stuff here */ };

              ....then you have a user-defined type (or UDT), whose type is MyClass.

              Likewise, the definition

              struct MyStruct { /* member stuff here */ };

              ....defines a UDT, whose type is MyStruct.

              (Sometimes in OOP, the terms "UDT" and "class" are used interchangeably , but
              to me that can be confusing, since in C++ we also have UDTs which are
              struct's, as I've shown.)

              Given the above definitions,

              MyClass aMyClassInstanc e;

              ....declares a variable called aMyClassInstanc e, whose type is MyClass, and

              MyStruct aMyStructInstan ce;

              ....declares a variable called aMyStructInstan ce, whose type is MyStruct, and

              -Howard




              Comment

              • Default User

                #8
                Re: type, class, object

                Howard wrote:
                >
                "Michael" <michaelnx@gmai l.comwrote in message
                news:1154540707 .145109.249480@ i3g2000cwc.goog legroups.com...
                I would think of type as "Class". Is thar right? There is no
                difference to call "Class" or "Type".
                >
                Where do you get the word "Class" from? Are you referring to the
                keyword "class", which denotes one kind of user-defined-type? (The
                other being the keyword "struct".)
                Poor ol' "union", forsaken again.




                Brian

                Comment

                Working...