Results 1 to 3 of 3

Thread: Is there any way to avoid the use of a class not created.

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Is there any way to avoid the use of a class not created.

    I have a class, in example, Myclass.
    I create an instance of it, in example, myclass;

    Sometimes I use, by mistake, Myclass.my_property. (uppercase)
    Ok, I can compile and run my program, but the value returned are wrong (and can do my program crash ).

    Can I solve this ? That is to say, how to avoid the use of classes not instanciated ?
    Thanks

    Ups, please move to general programming.
    Last edited by tonnot; 28th June 2011 at 14:01.

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Is there any way to avoid the use of a class not created.

    I can't get what you mean but do not have public member variables, use getters and setters. Another thing is that you can have all the needed parameters in the constructor, that cannot be instanciated without passing correct values.

  3. #3
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is there any way to avoid the use of a class not created.

    don't use a variable name that is almost like the class name

Similar Threads

  1. How to avoid border of QCanvas
    By olzzen in forum Qt Programming
    Replies: 3
    Last Post: 12th August 2010, 08:57
  2. How to avoid to repeat a connection
    By Auryn in forum Qt Programming
    Replies: 1
    Last Post: 8th July 2009, 15:47
  3. How can I avoid a QDialog close?
    By ricardo in forum Qt Programming
    Replies: 7
    Last Post: 11th May 2009, 19:29
  4. Replies: 3
    Last Post: 27th December 2008, 19:34
  5. Avoid full recompilation
    By ^NyAw^ in forum General Programming
    Replies: 15
    Last Post: 6th October 2008, 11:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.