| Author |
Message |
md

|
Posted: Wed Jan 17, 2007 7:12 pm Post subject: Re: Reading Full Lines |
|
|
ownageprince @ Wednesday 2007-01-17 6:26 pm wrote: i agree with wtd..why bother with structs when you can easily make class with much more useful as they are reuseable..
THAT'S NOT WHAT HE SAID.
Good god people. Wtd is saying that classes and structs are almost entirely the same. Either you know this, or you don't. And if you don't you should stop sprouting bullshit until you know what you are talking about. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
abcdefghijklmnopqrstuvwxy
|
Posted: Wed Jan 17, 2007 11:27 pm Post subject: RE:Reading Full Lines |
|
|
I just asked a simple question. Is structs considered bad form in C++?
My confusion stems from seeing many C++ sources making use of a struct. I am not a C programmer migrating to C++, and I was told never to use structs so why would I be an expert on structs?
I just wanted to know what the consesus, if there is one, on using structs is... Can someone give me a straight answer? |
|
|
|
|
 |
ericfourfour
|
|
|
|
 |
md

|
Posted: Thu Jan 18, 2007 2:49 am Post subject: RE:Reading Full Lines |
|
|
| There is nothing wrong with structs. Nothing. Anyone who tells you never to use them just doesn't know what they are talking about. |
|
|
|
|
 |
wtd
|
Posted: Thu Jan 18, 2007 3:01 am Post subject: RE:Reading Full Lines |
|
|
| I would tend to agree with md. |
|
|
|
|
 |
abcdefghijklmnopqrstuvwxy
|
Posted: Thu Jan 18, 2007 3:04 am Post subject: RE:Reading Full Lines |
|
|
Okay, from reading wtd's post on structs in the tutorial section it sounds like structs have been modified in c++ so that they are exactly like classes except public by default. I had to read it twice to get that... At first I thought he was saying to avoid using structs...
So for the record, structs = classes except public by default? That's the only difference? (In c++) |
|
|
|
|
 |
wtd
|
Posted: Thu Jan 18, 2007 3:47 am Post subject: RE:Reading Full Lines |
|
|
| Yes. |
|
|
|
|
 |
md

|
Posted: Thu Jan 18, 2007 1:04 pm Post subject: RE:Reading Full Lines |
|
|
That and struct is one letter longer then class when typing  |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
abcdefghijklmnopqrstuvwxy
|
Posted: Thu Jan 18, 2007 8:45 pm Post subject: RE:Reading Full Lines |
|
|
| One letter longer? Golly, now I know why I've been avoiding structs all this time! Thank God for classes! |
|
|
|
|
 |
ownageprince
|
Posted: Fri Jan 19, 2007 8:01 am Post subject: Re: Reading Full Lines |
|
|
md @ Wed Jan 17, 2007 7:12 pm wrote:
Good god people. Wtd is saying that classes and structs are almost entirely the same. Either you know this, or you don't. And if you don't you should stop sprouting bullshit until you know what you are talking about.
they are not almost entirely the same...in classes you have public, private and protected this enables you to hide data from the user depending under which heading you put it under.
also you can't define functions in structs...so they are not almost entirely the same my friend.. |
|
|
|
|
 |
abcdefghijklmnopqrstuvwxy
|
Posted: Fri Jan 19, 2007 9:45 am Post subject: RE:Reading Full Lines |
|
|
lol... you can declare public private or protected in c++ structs. you can define functions in c++ structs. I know that is what you meant to say
Note: In C you cannot do those things, but in C++ you can. They changed struct for C++.
So as md said it: stop sprouting bull shit... lmao... |
|
|
|
|
 |
md

|
Posted: Fri Jan 19, 2007 11:01 am Post subject: Re: Reading Full Lines |
|
|
ownageprince @ Friday 2007-01-19 8:01 am wrote: md @ Wed Jan 17, 2007 7:12 pm wrote:
Good god people. Wtd is saying that classes and structs are almost entirely the same. Either you know this, or you don't. And if you don't you should stop sprouting bullshit until you know what you are talking about.
they are not almost entirely the same...in classes you have public, private and protected this enables you to hide data from the user depending under which heading you put it under.
also you can't define functions in structs...so they are not almost entirely the same my friend..
You are wrong. Structs can contain public, private and protected data and functions. In C++ structs are the exact same thing as classes, except that structs are public by default. I would also really recommend knowing what you're talking about before you go saying that two of the more knowledgeable people are wrong; especially about a language that one (me) uses almost daily. |
|
|
|
|
 |
deville75

|
Posted: Fri Jan 19, 2007 11:15 am Post subject: RE:Reading Full Lines |
|
|
| Is a struct only used to create simple types? |
|
|
|
|
 |
Andy
|
Posted: Fri Jan 19, 2007 12:48 pm Post subject: RE:Reading Full Lines |
|
|
| err what? clearly you dont know what structs are then. |
|
|
|
|
 |
wtd
|
Posted: Fri Jan 19, 2007 12:56 pm Post subject: RE:Reading Full Lines |
|
|
| It's a shame there isn't a thread where people have recently had a fairly thorough discussion on this subject. |
|
|
|
|
 |
|