Why can't structs have constructors?

R

Ron

That's pretty much the same as asking "Why can't eagles fly?"

Yep...the only difference between a struct and class is the
default access specifier (public in struct, private in class).
 
B

BGB / cr88192

Juha Nieminen said:
Let me guess: What you *really* wanted to ask was: Why can't unions
have constructors?

it is because of the amount of actual labor involved...
 
S

saurabh

Why can't structs have constructors?

They can.Looks like you studied structures from a C book,and then left
the structure topic while starting c++.
The only difference between Structures and Classes is ,that by default
everything in a class is private while everything in a struct by default
is public.
 

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

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top