View Poll Results: Best Keyword. And Easiest.

Voters
28. You may not vote on this poll
  • mutable

    2 7.14%
  • class

    7 25.00%
  • extern

    1 3.57%
  • sizeof

    5 17.86%
  • void

    3 10.71%
  • typedef

    0 0%
  • extern

    0 0%
  • int

    10 35.71%

Thread: Best Keyword

  1. #1
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361

    Best Keyword

    Please place your vote

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    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

  3. #3
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Why choose class over sizeof? It's unheard of. I prefer sizeof, it's much easier to type and it sounds better.

  4. #4
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    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

  5. #5
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    What! That's impossible. Where's this thread?

  6. #6
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    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

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Originally posted by FillYourBrain
    it's not impossible. I gave the solution...

    type *t=0;
    t++;
    int size = (int)t;
    You gave a solution, yes. There are more than one just so everyone knows

  8. #8
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    you're evil
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  9. #9
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Originally posted by FillYourBrain
    you're evil
    Thats what they tell me.
    "...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

  10. #10
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    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

  11. #11
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    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.
    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.
    "...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

  12. #12
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    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;
    }

  13. #13
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    ... this ... thread ... makes ... no ... sense ...

  14. #14
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    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

  15. #15
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Thumbs down Why choose???

    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.
    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!
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. keyword replacement
    By JackBear in forum C Programming
    Replies: 11
    Last Post: 05-18-2007, 10:54 PM
  2. Virtual Keyword
    By Shal in forum C++ Programming
    Replies: 6
    Last Post: 05-18-2006, 11:37 AM
  3. 'new' keyword
    By pktcperlc++java in forum C++ Programming
    Replies: 4
    Last Post: 02-28-2005, 09:31 PM
  4. how to search a keyword in C?
    By kreyes in forum C Programming
    Replies: 2
    Last Post: 03-01-2002, 08:22 PM
  5. keyword searching in C
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 02-08-2002, 02:26 AM