Results 1 to 8 of 8

Thread: How do you do static constants right?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: How do you do static constants right?

    Or you can just define it outside SerialCommunication in the .cpp file.
    J-P Nurmi

  2. #2
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    101
    Thanked 15 Times in 15 Posts

    Default Re: How do you do static constants right?

    You mean...global variables that are not members of the class? *scared*

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: How do you do static constants right?

    But if you make it static, it's only visible inside the compilation unit.
    J-P Nurmi

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    6
    Thanked 163 Times in 151 Posts

    Default Re: How do you do static constants right?

    or use an enum:
    Qt Code:
    1. class SerialCommunication
    2. {
    3. private:
    4. enum { RX_BUFFER_SIZE = 128 };
    5. };
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to caduel for this useful post:

    Cruz (6th February 2009)

Similar Threads

  1. How to use static mysql plugin
    By khikho in forum Qt Programming
    Replies: 7
    Last Post: 19th January 2009, 21:44
  2. Replies: 22
    Last Post: 8th October 2008, 13:54
  3. new problem with simple C++ static variables
    By landonmkelsey in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2008, 05:42
  4. Replies: 16
    Last Post: 23rd May 2008, 10:12
  5. Accessing to a static variable from the same class
    By xgoan in forum General Programming
    Replies: 6
    Last Post: 5th March 2007, 10:50

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
  •  
Qt is a trademark of The Qt Company.