NewBie Question

D

david

Hi All,

I am a newbie using C++. I wanna know what are the differences between
Class and Structure ? Thanks in advance.

Best Regards,
David
 
R

Ron Natalie

david said:
Hi All,

I am a newbie using C++. I wanna know what are the differences between
Class and Structure ? Thanks in advance.

Structs are classes that have the default access public (rather than private).
There is no other difference.
 
S

Sam Holden

"Ron Natalie

Also Structs do not use inheritance.

That's completely false. Structs do inheritance just fine, in fact you
could argue they do it "better" than classes, since they default to
public inheritance which is probably the more common usage.
 
B

Bob Jacobs

Newsnet Customer said:
The book im reading says "the definition of a structure has only data
fields, in which all access is public, and that does not use inheritance".
I personally have never used structures as it is no longer in vogue
since the introduction of the class data type. Those that still use it
show their age in C++ programming.

Please identify the title, author, and year of publication, of your book.
 
J

jeffc

Newsnet Customer said:
The book im reading says "the definition of a structure has only data
fields, in which all access is public, and that does not use inheritance". I
personally have never used structures as it is no longer in vogue since the
introduction of the class data type. Those that still use it show their age
in C++ programming.

Then apparently either you or the book are confusing the word "structure"
with the C++ keyword "struct".
 
A

Agent Mulder

<Sam>
Structs do inheritance just fine, in fact you could argue
they do it "better" than classes, since they default to
public inheritance which is probably the more common
usage.
</Sam>

Right. A struct and a class are EXACT the
same EXCEPT for the default access specifier.
When you find yourself in an environment without
classes but with struct in abundance, like Windows,
get familiar with inheriting these structs and treat
them like classes and your code will fly.

-X
 
N

Newsnet Customer

inheritance".

Then apparently either you or the book are confusing the word "structure"
with the C++ keyword "struct".


Sorry, I misinterpreted the book.

The struct datatype is exactly like the class datatype except that the
members all have public access by default.

asasas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Newbie 0
Newbie to coding and wanting to learn 2
Facial Recognition Door Handles 0
Intro and asking for direction.(newbie am I) 2
Build My Own CRM 1
Hi Im a Womble 4
C programming 5
Get Into Google-The Resume 0

Staff online

Members online

Forum statistics

Threads
474,142
Messages
2,570,818
Members
47,362
Latest member
eitamoro

Latest Threads

Top