Static class == NULL

This is a discussion on Static class == NULL within the C++ Programming forums, part of the General Programming Boards category; Hello! I have serveral classes with static variables/methods. I want to check objects from these classes whether they are NULL ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    19

    Static class == NULL

    Hello!

    I have serveral classes with static variables/methods. I want to check objects from these classes whether they are NULL or not this way:

    Code:
    MyClassWithStaticFunctions *x;
    if (!x) printf("x is null");
    "x" never seems to be NULL. How can this be?

    Greetings,

  2. #2
    Registered User
    Join Date
    Sep 2005
    Posts
    19
    already got it working...

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    I'm guessing you figured out the fact that variables aren't initiallized to a default value in the language spec, and that only some compilers might set a pointer to null at creation, others will use something else, or possibly just leave it with the garbage already in memory.
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 04:06 PM
  2. Tic Tac Toe!
    By Sinensis in forum C Programming
    Replies: 2
    Last Post: 10-21-2008, 05:40 PM
  3. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 08:05 AM
  4. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 01:13 AM
  5. Massive Function Problem
    By Marc Sharp in forum C Programming
    Replies: 10
    Last Post: 11-19-2003, 08:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21