Connecting Tech Pros Worldwide Forums | Help | Site Map

Difference between c structure and c++ structure

raghunandan_1081@yahoo.com
Guest
 
Posts: n/a
#1: Mar 18 '06
Hi guys, can you please tell me what is the Difference between c
structure and c++ structure


Bob Hairgrove
Guest
 
Posts: n/a
#2: Mar 18 '06

re: Difference between c structure and c++ structure


On 18 Mar 2006 03:30:20 -0800, raghunandan_1081@yahoo.com wrote:
[color=blue]
>Hi guys, can you please tell me what is the Difference between c
>structure and c++ structure[/color]

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

--
Bob Hairgrove
NoSpamPlease@Home.com
opalpa@gmail.com opalinski from opalpaweb
Guest
 
Posts: n/a
#3: Mar 18 '06

re: Difference between c structure and c++ structure


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
opalpa@gmail.com

Kai-Uwe Bux
Guest
 
Posts: n/a
#4: Mar 18 '06

re: Difference between c structure and c++ structure


opalpa@gmail.com opalinski from opalpaweb wrote:
[color=blue]
> 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.[/color]

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).
[color=blue]
> 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.[/color]


Best

Kai-Uwe Bux



opalpa@gmail.com opalinski from opalpaweb
Guest
 
Posts: n/a
#5: Mar 18 '06

re: Difference between c structure and c++ structure


> Since the only difference between a C++ struct and a C++ class is the[color=blue]
> 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).[/color]

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

Opalinski
opalpa@gmail.com
http://www.geocities.com/opalpaweb/

osmium
Guest
 
Posts: n/a
#6: Mar 18 '06

re: Difference between c structure and c++ structure


<raghunandan_1081@yahoo.com> wrote:
[color=blue]
> Hi guys, can you please tell me what is the Difference between c
> structure and c++ structure[/color]

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.


Bob Hairgrove
Guest
 
Posts: n/a
#7: Mar 18 '06

re: Difference between c structure and c++ structure


On Sat, 18 Mar 2006 06:28:01 -0800, "osmium" <r124c4u102@comcast.net>
wrote:
[color=blue]
><raghunandan_1081@yahoo.com> wrote:
>[color=green]
>> Hi guys, can you please tell me what is the Difference between c
>> structure and c++ structure[/color]
>
>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.
>[/color]

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
NoSpamPlease@Home.com
Gimmmo
Guest
 
Posts: n/a
#8: May 8 '06

re: Difference between c structure and c++ structure


On Sat, 18 Mar 2006 15:48:10 +0100, Bob Hairgrove wrote:
[color=blue]
> On Sat, 18 Mar 2006 06:28:01 -0800, "osmium" <r124c4u102@comcast.net>
> wrote:
>[color=green]
>><raghunandan_1081@yahoo.com> wrote:
>>[color=darkred]
>>> Hi guys, can you please tell me what is the Difference between c
>>> structure and c++ structure[/color]
>>
>>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.[/color]
>
> 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.[/color]

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.

Closed Thread