Saturday, April 9, 2005

Mmm, structs...

Is it bad that I'm starting to think that structs look pretty? At least that's better than thinking them tasty, right?

5 comments:

Joseph said...

As long as you don't go into the realm of structS being "sexy"

Lisa R said...

Umm... what are structS? *g*

Forrest said...

But they're so much less pretty in C than in C#... C's structs seem like cheap whores in comparison.

Arthaey Angosii said...

Joe: Structs, sexy? That's just sick.

Forrest: No, no. See, C structs are simple and thus have a certain clean elegance to them. C++ are more useful and fancy, but not as pretty. Like 26. Very pretty number. See? ;)

Loodle: Ah, poor non-programmer. You can think of a struct as a little bundle of related information. For example, you could have a "person" struct that bundles together, say, name and age:


struct person {
string name; /* programmers: it's typedef'd, go away */
int age; /* "int" is short for "integer" */
}


Then, elsewhere in the program's code, I could create a person struct and get its bundled information back out of it:


struct person someone = {"Arthaey", 21};
display(someone.name); /* displays "Arthaey" */
display(someone.age); /* displays 21 */


Even you could do this! It's easier than zMud scripting, maybe. :)

Forrest said...

C#'s structs tho, can be just as simple, but they let you do so much more if you like. There is that little bit of rtti but i think that's justifiable.