Please place your vote
mutable
class
extern
sizeof
void
typedef
extern
int
Please place your vote
I didn't think anyone was actually going to do this. Oh well. I can tell you that my least favorite on that list is extern. I think extern should be banned as it is a way of making everything super-global.
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
Why choose class over sizeof? It's unheard of. I prefer sizeof, it's much easier to type and it sounds better.
while sizeof may be nice, I choose class from my position as an OOP advocate. there was just a thread on finding a type's size without using sizeof (silly beginners ).
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
What! That's impossible. Where's this thread?
it's not impossible. I gave the solution...
type *t=0;
t++;
int size = (int)t;
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
You gave a solution, yes. There are more than one just so everyone knowsOriginally posted by FillYourBrain
it's not impossible. I gave the solution...
type *t=0;
t++;
int size = (int)t;
you're evil
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
Thats what they tell me.Originally posted by FillYourBrain
you're evil
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
for the record, I meant "I gave the solution" as in "I gave the following solution" not that I am God and I solved the world's problems.
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
Yeah, and I realize that. I only posted my response because I like to encourage people to find many solutions to problems. I didn't want them to think there was only one way to do it.Originally posted by FillYourBrain
for the record, I meant "I gave the solution" as in "I gave the following solution" not that I am God and I solved the world's problems.
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
Playing around with FYB's idea I came up with an interesting, (albeit ludicrous) application, using it as a sort of data-hiding mechanism.
Code:class access_level { public: virtual void access() = 0; }; class denial : public access_level { public: int a; void access(){ MessageBox(NULL, "Get outa here!", "Access Denied!!", MB_OK); } }; class level_3 : public access_level { public: int a, b; void access(){ MessageBox(NULL, "Free to roam the bottom floor.", "Hello employee.", MB_OK); } }; class level_2 : public access_level { public: int a, b, c; void access(){ MessageBox(NULL, "Free to browse.", "Good day, supervisor.", MB_OK); } }; class level_1 : public access_level { public: int a, b, c, d; void access(){ MessageBox(NULL, "You may do as you wish", "Top of the day, Mr. President.", MB_OK); } }; void * security_level_token(){ void * key_type = NULL; void * employee = ((level_3*)NULL+1); void * supervisor = ((level_2*)NULL+1); void * president = ((level_1*)NULL+1); /* Add code to determine what admin level we're currently running in... */ key_type = president; //...change this line...// return key_type; } access_level * access_point(void * unknown){ access_level * privilage = (access_level*)unknown; int type = (int)privilage; if(type == sizeof(level_3)) return new level_3; else if(type == sizeof(level_2)) return new level_2; else if(type == sizeof(level_1)) return new level_1; return new denial; } int main(){ /* caller knows no details of the implementation */ void * unknown_level = security_level_token(); access_level * my_level = access_point(unknown_level); my_level->access(); return 0; }
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Hehe I was being sarcastic when I wrote this:
http://www.cprogramming.com/cboard/s...832#post195525
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
I agree and class is not a fav of mine either. I guess the only one i really like in here is "int". HE! HE! HE!Originally posted by Eibro
Why choose class over sizeof? It's unheard of. I prefer sizeof, it's much easier to type and it sounds better.
Later,
cj
"Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
-Bruce Lee