Results 1 to 10 of 10

Thread: 'Class' does not name a type error

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Location
    Australia
    Posts
    44
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default 'Class' does not name a type error

    hi, its probably some silly mistake in c++ but my code is not working, it gives me error.

    here is code

    _time.h
    Qt Code:
    1. #ifndef _TIME_H
    2. #define _TIME_H
    3.  
    4. #include <QObject>
    5. #include <QTimer>
    6.  
    7. class _Time : public QObject
    8. {
    9. Q_OBJECT
    10. public:
    11. _Time();
    12. _Time(int sec=0,int min=0,int hour=0);
    13. int hour;
    14. int min;
    15. int sec;
    16. };
    17. #endif // _TIME_H
    To copy to clipboard, switch view to plain text mode 

    _time.cpp
    Qt Code:
    1. #include "_time.h"
    2.  
    3. _Time::_Time()
    4. {
    5.  
    6. hour=0;
    7. min=0;
    8. sec=0;
    9.  
    10. }
    11. _Time::_Time(int s, int m, int h)
    12. {
    13.  
    14. if (h > -1)
    15. hour=h;
    16. else
    17. hour=0;
    18.  
    19. if ((m > -1) && (m<60))
    20. min=m;
    21. else
    22. min=0;
    23.  
    24. if ((s > -1) && (s<60))
    25. sec=s;
    26. else
    27. sec=0;
    28.  
    29.  
    30. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp

    Qt Code:
    1. #include "_time.h"
    2. _Time t;
    3. int main(int argc, char *argv[])
    4. {
    5.  
    6.  
    7. return 0;
    8. }
    To copy to clipboard, switch view to plain text mode 

    i get error:
    _Time does not name a type.

    any suggestions? thanks in advance
    Last edited by naturalpsychic; 31st January 2011 at 17:34. Reason: code correction
    Life is like a dream, sometimes it is good and somtimes it is bad, but in the end it is over

Similar Threads

  1. error ISO C++ forbids declaration of 'obj' with no type
    By naturalpsychic in forum Qt Programming
    Replies: 1
    Last Post: 26th January 2011, 06:23
  2. Replies: 12
    Last Post: 28th May 2010, 00:07
  3. Determine Class Type of QObject Parent
    By photo_tom in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2010, 17:42
  4. Replies: 3
    Last Post: 27th December 2008, 19:34
  5. Data type error
    By MrShahi in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2008, 14:01

Tags for this Thread

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.