Struct or class?
Collapse
This topic is closed.
X
X
-
George2Tags: None -
Rolf Magnus
Re: Struct or class?
George2 wrote:
I don't know why it does. I guess you'd have to ask the author.Hello everyone,
>
>
Multiplies is a struct, why MSDN said it is a class?
Anyway, in C++, a struct and a class are basically the same thing.
-
Rolf Magnus
Re: Struct or class?
George2 wrote:
I don't know why it does. I guess you'd have to ask the author.Hello everyone,
>
>
Multiplies is a struct, why MSDN said it is a class?
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++
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
Re: Struct or class?
On Dec 5, 5:37 pm, C++ <davidc...@wana doo.frwrote:Well, that's true. But then what was the need of introducing a classThere is only one difference between classe and strucure.
Defaut view for classes is private and for structures it's public
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
Re: Struct or class?
matfarell@gmail .com wrote:I'd guess the idea was that by making the default access modifierOn 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".
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
Re: Struct or class?
"C++" <davidcome@wana doo.frwrote in message
news:op.t2u30hw vxzmhlk@debian. ..By "default view" I assume you meant default visibility of its members.There is only one difference between classe and strucure.
Defaut view for classes is private and for structures it's public
Also, default inheritance for struct is public, and private for class.
-Howard
Comment
-
terminator
Re: Struct or class?
On Dec 5, 4:15 pm, matfar...@gmail .com wrote:I think they were not certian about future and thought that semanticsOn 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".
of class were about to change .
regards,
FM.
Comment
-
James Kanze
Re: Struct or class?
On Dec 5, 12:54 pm, George2 <george4acade.. .@yahoo.comwrot e:
Because it is a class. There are no structs in C++.Multiplies is a struct, why MSDN said it is a class?
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
Comment