Struct or class?

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

    Struct or class?

    Hello everyone,


    Multiplies is a struct, why MSDN said it is a class?




    thanks in advance,
    George
  • Rolf Magnus

    #2
    Re: Struct or class?

    George2 wrote:
    Hello everyone,
    >
    >
    Multiplies is a struct, why MSDN said it is a class?
    I don't know why it does. I guess you'd have to ask the author.
    Anyway, in C++, a struct and a class are basically the same thing.

    Comment

    • Rolf Magnus

      #3
      Re: Struct or class?

      George2 wrote:
      Hello everyone,
      >
      >
      Multiplies is a struct, why MSDN said it is a class?
      I don't know why it does. I guess you'd have to ask the author.
      Anyway, in C++, a struct and a class are basically the same thing. But
      actually, multiplies is neither a struct nor a class. It's a template.


      Comment

      • C++

        #4
        Re: Struct or class?

        There is only one difference between classe and strucure.
        Defaut view for classes is private and for structures it's public

        Comment

        • matfarell@gmail.com

          #5
          Re: Struct or class?

          On Dec 5, 5:37 pm, C++ <davidc...@wana doo.frwrote:
          There is only one difference between classe and strucure.
          Defaut view for classes is private and for structures it's public
          Well, that's true. But then what was the need of introducing a class
          when a struct was already there? I mean that when C++ was designed,
          Stroustrup may have thought of it. But "as a beginner" i still wonder
          why a class was incorporated , even though struct was already there
          "doing the work".

          Comment

          • Alan Woodland

            #6
            Re: Struct or class?

            matfarell@gmail .com wrote:
            On Dec 5, 5:37 pm, C++ <davidc...@wana doo.frwrote:
            >There is only one difference between classe and strucure.
            >Defaut view for classes is private and for structures it's public
            >
            Well, that's true. But then what was the need of introducing a class
            when a struct was already there? I mean that when C++ was designed,
            Stroustrup may have thought of it. But "as a beginner" i still wonder
            why a class was incorporated , even though struct was already there
            "doing the work".
            I'd guess the idea was that by making the default access modifier
            private it would encourage information hiding and encapsulation. Of
            course to maintain backwards compatibility with C you can't just change
            the default with structs, otherwise everything would break, hence the
            need for a new keyword. Additionally I'd argue that it serves to
            encourage developers moving from C to C++ to think about things in a
            different frame of mind and to use the new features of the OO paradigm
            that C++ makes available.

            That's just my view though, and I'm sure someone out there has more
            historical knowledge on this one..

            Alan

            Comment

            • Howard

              #7
              Re: Struct or class?


              "C++" <davidcome@wana doo.frwrote in message
              news:op.t2u30hw vxzmhlk@debian. ..
              There is only one difference between classe and strucure.
              Defaut view for classes is private and for structures it's public
              By "default view" I assume you meant default visibility of its members.
              Also, default inheritance for struct is public, and private for class.
              -Howard

              Comment

              • terminator

                #8
                Re: Struct or class?

                On Dec 5, 4:15 pm, matfar...@gmail .com wrote:
                On Dec 5, 5:37 pm, C++ <davidc...@wana doo.frwrote:
                >
                There is only one difference between classe and strucure.
                Defaut view for classes is private and for structures it's public
                >
                Well, that's true. But then what was the need of introducing a class
                when a struct was already there? I mean that when C++ was designed,
                Stroustrup may have thought of it. But "as a beginner" i still wonder
                why a class was incorporated , even though struct was already there
                "doing the work".
                I think they were not certian about future and thought that semantics
                of class were about to change .

                regards,
                FM.

                Comment

                • James Kanze

                  #9
                  Re: Struct or class?

                  On Dec 5, 12:54 pm, George2 <george4acade.. .@yahoo.comwrot e:
                  Multiplies is a struct, why MSDN said it is a class?
                  Because it is a class. There are no structs in C++.

                  There are two different keywords which can be used to define a
                  class: struct and class. Conventions concerning their use vary:
                  some people limit struct to pure POD's, others use it anytime
                  all members are public, and still others (like myself) if all
                  data members are public. In the latter case, some will use
                  struct if there are no data members, others will use class (and
                  others, like myself, are somewhat inconsistent). Regardless of
                  the keyword used, however, what is defined is a class.

                  --
                  James Kanze (GABI Software) email:james.kan ze@gmail.com
                  Conseils en informatique orientée objet/
                  Beratung in objektorientier ter Datenverarbeitu ng
                  9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

                  Comment

                  Working...