Results 1 to 3 of 3

Thread: extern class

  1. #1
    Join Date
    Jan 2007
    Posts
    95
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default extern class

    Hi. I want to define a global class variable. I have defined in my main.cpp this:
    IDIOMA lang; //IDIOMA is the class name.
    and then in other .cpp I have write:
    extern IDIOMA lang;
    I have no compiler error and no linker error, but when i used some member of lang is empty (lang.number for example).

    What happend? How can I defined a global class variable that i can used in all modules of my programm?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: extern class

    It looks like you do everything right. Did you remember to initialize lang? Do you have any other global variables or maybe static ones?

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: extern class

    Or implement a singleton class.

Similar Threads

  1. How i will use treeWidget of GUI class in thread class
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 15th May 2007, 15:31
  2. Creating object of other class in Run() method
    By santosh.kumar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2007, 15:05
  3. Replies: 2
    Last Post: 16th March 2007, 09:04
  4. Replies: 2
    Last Post: 4th May 2006, 19:17
  5. How to propagate from one class to another
    By mahe2310 in forum Qt Programming
    Replies: 15
    Last Post: 20th March 2006, 01:27

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.