473,805 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Difference between c structure and c++ structure

Hi guys, can you please tell me what is the Difference between c
structure and c++ structure

Mar 18 '06 #1
7 12375
On 18 Mar 2006 03:30:20 -0800, ra************* *@yahoo.com wrote:
Hi guys, can you please tell me what is the Difference between c
structure and c++ structure


FAQ: http://www.parashift.com/c++-faq-lit...d-objects.html

--
Bob Hairgrove
No**********@Ho me.com
Mar 18 '06 #2
None of the eight questions in page under FAQ link match question
asked, in my opinion. I suppose you could interpret the OP's question
to be a comparison between C struct and C++ class, but I read OP's
question as a comparison between C struct and C++ struct.

One difference between C struct and C++ struct is that C++ struct can
have methods inside. Another difference is that parts of C++ struct
can be "hidden" by being made private.

Opalinski
http://www.geocities.com/opalpaweb
op****@gmail.co m

Mar 18 '06 #3
op****@gmail.co m opalinski from opalpaweb wrote:
None of the eight questions in page under FAQ link match question
asked, in my opinion. I suppose you could interpret the OP's question
to be a comparison between C struct and C++ class, but I read OP's
question as a comparison between C struct and C++ struct.
Since the only difference between a C++ struct and a C++ class is the
default access (public for struct, private for class), the explanation in
"what is a class" together with "what's the difference between the keywords
struct and class" should answer the question of the OP (assuming the OP
knows C structs).
One difference between C struct and C++ struct is that C++ struct can
have methods inside. Another difference is that parts of C++ struct
can be "hidden" by being made private.

Best

Kai-Uwe Bux

Mar 18 '06 #4
> Since the only difference between a C++ struct and a C++ class is the
default access (public for struct, private for class), the explanation in
"what is a class" together with "what's the difference between the keywords
struct and class" should answer the question of the OP (assuming the OP
knows C structs).


I agree. Good point. With the above directions OP will be fine.

Opalinski
op****@gmail.co m
http://www.geocities.com/opalpaweb/

Mar 18 '06 #5
<ra************ **@yahoo.com> wrote:
Hi guys, can you please tell me what is the Difference between c
structure and c++ structure


The syntax for using a struct is different in C than C++.

In C++ struct is a type, and can be referred to much like an int. Not so in
C.
Mar 18 '06 #6
On Sat, 18 Mar 2006 06:28:01 -0800, "osmium" <r1********@com cast.net>
wrote:
<ra*********** ***@yahoo.com> wrote:
Hi guys, can you please tell me what is the Difference between c
structure and c++ structure


The syntax for using a struct is different in C than C++.

In C++ struct is a type, and can be referred to much like an int. Not so in
C.


Actually it is also a type, except that you have to prefix every use
of the name with the keyword "struct" unless you declare it as a
typedef.

As you say, of course, the syntax is different, but types in C have
different semantics than in C++ anyway.

--
Bob Hairgrove
No**********@Ho me.com
Mar 18 '06 #7
On Sat, 18 Mar 2006 15:48:10 +0100, Bob Hairgrove wrote:
On Sat, 18 Mar 2006 06:28:01 -0800, "osmium" <r1********@com cast.net>
wrote:
<ra********** ****@yahoo.com> wrote:
Hi guys, can you please tell me what is the Difference between c
structure and c++ structure


The syntax for using a struct is different in C than C++.

In C++ struct is a type, and can be referred to much like an int. Not so in
C.


Actually it is also a type, except that you have to prefix every use
of the name with the keyword "struct" unless you declare it as a
typedef.


struct A {
char x;
int y;
};

struct A A1;

struct A A2;
A2.x = 1;
A2.y = 600;

In C:
A1 = A2; <--- can do?
If i'm not wrong, must use memcpy() byte by byte.

In C++:
A1 = A2; <--- can do?
Rgds.

May 8 '06 #8

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

Similar topics

22
3365
by: Ook | last post by:
We have had a discussion on the differences between a class and a structure, and no one is in agreement. As I understand it, a structure defaults to public, a class defaults to private. There are issues about constructors that I'm not clear on. I do know that I can take a simple project with a class that has constuctors, destructors, accessors, and modifiers, change the classes to structs, and it compiles and runs fine. Can some kind soul...
3
4436
by: Eric J.Hu | last post by:
Hi, Such as I have following bitmap structure and assigned value: struct bm { char high2bits:2; char mid4bits:4; char low2bits:2; }; bm.high2bits = 3;
5
8735
by: Chris | last post by:
Hi, I don't get the difference between a struct and a class ! ok, I know that a struct is a value type, the other a reference type, I understand the technical differences between both, but conceptually speaking : when do I define something as 'struct' and when as 'class' ? for example : if I want to represent a 'Time' thing, containing : - data members : hours, mins, secs
6
71984
by: John Pass | last post by:
What is the difference between a While and Do While/Loop repetition structure. If they is no difference (as it seems) why do both exist?
1
1251
by: cashdeskmac | last post by:
Can anyone tell me the difference between these two xml files: <?xml version="1.0" ?> <Bookshop> <book title="my first book" author="someone"/> <book title="another book" author="someone else"/> <DVD title="how to cook" director="TV Chef"/> <DVD title="Gardening" director="TV gardener"/> </Bookshop>
5
2282
by: narutocanada | last post by:
hi what is the difference between the two kinds of brackets? I tried a few examples but I can't make out any real difference: lst = print lst print lst print lst lst = (10, 20, 30) print lst
4
171497
by: msukumarbabu | last post by:
Hi all, What will be difference between "typedef enum" and "enum". or difference between “typedef structure" and "structure" I am going through some code. in that some place they are using enum without typedef. In some places they are using typedef before enumeration definition. Kindly provide some reference, for why they are using typedef.
9
3322
by: jinendrashankar | last post by:
Hi All, Can any one have any idea about this issue what is Difference between structure and class in C++ Other then by default structure have public scope and class have private scope For data member and member function .If there is no other difference between Class & structure then why we use 2 key world in C++ we can use either class or structure in C++ ?
1
2624
rizwan6feb
by: rizwan6feb | last post by:
I am developing an application in VB.net 2005 that synchronizes two mysql databases of same structure. I have done most of the work but having problem in finding the difference in records in 2 tables. Let me explain the scenario There is a table in the local database having name "user". The same table exists in the online version of the database. I want to find the difference of records in the 2 tables so that i can delete surplus users from...
0
10614
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10369
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10109
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.