473,410 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Struct or class?

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

http://msdn2.microsoft.com/en-us/lib...ay(VS.80).aspx
thanks in advance,
George
Dec 5 '07 #1
8 1453
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.

Dec 5 '07 #2
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.
Dec 5 '07 #3
C++
There is only one difference between classe and strucure.
Defaut view for classes is private and for structures it's public
Dec 5 '07 #4
On Dec 5, 5:37 pm, C++ <davidc...@wanadoo.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".
Dec 5 '07 #5
ma*******@gmail.com wrote:
On Dec 5, 5:37 pm, C++ <davidc...@wanadoo.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
Dec 5 '07 #6

"C++" <da*******@wanadoo.frwrote in message
news:op.t2u30hwvxzmhlk@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

Dec 5 '07 #7
On Dec 5, 4:15 pm, matfar...@gmail.com wrote:
On Dec 5, 5:37 pm, C++ <davidc...@wanadoo.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.
Dec 5 '07 #8
On Dec 5, 12:54 pm, George2 <george4acade...@yahoo.comwrote:
Multiplies is a struct, why MSDN said it is a class?
http://msdn2.microsoft.com/en-us/lib...ay(VS.80).aspx
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:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Dec 6 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Kilana | last post by:
I see this all the time in code: typedef struct a_struct { ... }differentName, *differentNamePtr; I understand how I can use it, but could someone tell me why the above is
2
by: SACHIN | last post by:
I have this class as part of a Consol application. using System; namespace Bugreport { /// <summary> /// This class tries to use the Class/Struct combination. /// </summary> class Class1 {
4
by: Steve | last post by:
I'll be the first to admit, I'm not entirely clear on the appropriate usage of either. From what I am reading in my books, a Struct and a Class are pretty much the same, with the difference being,...
15
by: Steven T. Hatton | last post by:
The following may strike many of you as just plain silly, but it represents the kind of delelima I find myself in when trying to make a design decision. This really is a toy project written for...
15
by: bugzilla | last post by:
hi,all, I have a C++ program need to convert to c language to be used in a emabedded system. the problem is that the original code was writtern in C++ language with Parent class and some child...
3
by: Karl M | last post by:
Hi everyone, I just notice some strange behaviors on the MS C++ compiler regarding struct default constructor, see the example bellow: struct MyStruct { int a; }; class MyClass { public:
4
by: DaHool | last post by:
Hi there !!! I browsed around the Internet in search for a solution of a little difficult problem i have in VB.NET.... However, i cannot find a suitable anwser anywhere, so i thought i'll give...
5
by: jwright | last post by:
I have decided to use a struct to collect my data. The input file is comma dilineated between almost all of the fields. Here is the code I have so far and a sample input and output file. ...
1
by: stromhau | last post by:
Hi, I have made a few classes in c++. They somehow cooperate doing some 3d stuff. Basically it is a moving camera acting as a flight, i have placed a lot of objects around the scene together with...
2
by: Ninereeds | last post by:
I'm messing around with using mixin-layers (look for papers by Yannis Smaragdakis and Don Batory) to define data structures. One issue is that nodes tend to have pointers to other nodes - the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.