Unknown Class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    Unknown Class

    Hi,
    I have attached a program source with the question. I am not comfortable with C++. But the program is giving a strange problem.
    problem 1:
    It work nice in debug mode. but when i try to compile in release it generates error. No idea why is that.
    problem 2:
    the second problem was asked before but didnt got any real solution. focusing problem. focus is not changing by pressing TAB button
    (its not a big program or its not under any big plan. Just trying to be more comfortable with OOP)
    Any suggestion, criticism will be appreciated.
    Best Regards,
    Johny
    Attached Files
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    If you are getting errors then you should post them.

    Comment

    • johny10151981
      Top Contributor
      • Jan 2010
      • 1059

      #3
      Yes, My bad
      Code:
      1>------ Build started: Project: mysql_manager, Configuration: Release Win32 ------
      1>Compiling...
      1>stdafx.cpp
      1>Compiling...
      1>username_password.cpp
      1>.\username_password.cpp(12) : error C2653: 'username_password' : is not a class or namespace name
      1>.\username_password.cpp(15) : error C2673: 'getPassword' : global functions do not have 'this' pointers
      1>.\username_password.cpp(15) : error C2227: left of '->password' must point to class/struct/union/generic type
      1>.\username_password.cpp(17) : warning C4172: returning address of local variable or temporary
      1>.\username_password.cpp(20) : error C2653: 'username_password' : is not a class or namespace name
      1>.\username_password.cpp(23) : error C2673: 'getPortAddress' : global functions do not have 'this' pointers
      1>.\username_password.cpp(23) : error C2227: left of '->port' must point to class/struct/union/generic type
      1>.\username_password.cpp(24) : warning C4172: returning address of local variable or temporary
      1>.\username_password.cpp(27) : error C2653: 'username_password' : is not a class or namespace name
      1>.\username_password.cpp(30) : error C2673: 'getServerAddress' : global functions do not have 'this' pointers
      1>.\username_password.cpp(30) : error C2227: left of '->server_address' must point to class/struct/union/generic type
      1>.\username_password.cpp(31) : error C2673: 'getServerAddress' : global functions do not have 'this' pointers
      1>.\username_password.cpp(31) : error C2227: left of '->server_address' must point to class/struct/union/generic type
      1>.\username_password.cpp(33) : error C2653: 'username_password' : is not a class or namespace name
      1>.\username_password.cpp(36) : error C2673: 'getUserName' : global functions do not have 'this' pointers
      1>.\username_password.cpp(36) : error C2227: left of '->username' must point to class/struct/union/generic type
      1>.\username_password.cpp(37) : error C2673: 'getUserName' : global functions do not have 'this' pointers
      1>.\username_password.cpp(37) : error C2227: left of '->username' must point to class/struct/union/generic type
      1>.\username_password.cpp(41) : error C2653: 'username_password' : is not a class or namespace name
      1>.\username_password.cpp(43) : error C2673: 'setPassword' : global functions do not have 'this' pointers
      1>.\username_password.cpp(43) : error C2227: left of '->password' must point to class/struct/union/generic type
      1>.\username_password.cpp(46) : error C2653: 'username_password' : is not a class or namespace name
      1>.\username_password.cpp(48) : error C2673: 'setPortAddress' : global functions do not have 'this' pointers
      1>.\username_password.cpp(48) : error C2227: left of '->port' must point to class/struct/union/generic type
      1>.\username_password.cpp(51) : error C2653: 'username_password' : is not a class or namespace name
      1>.\username_password.cpp(53) : error C2673: 'setServerAddress' : global functions do not have 'this' pointers
      1>.\username_password.cpp(53) : error C2227: left of '->server_address' must point to class/struct/union/generic type
      1>.\username_password.cpp(55) : error C2653: 'username_password' : is not a class or namespace name
      1>.\username_password.cpp(57) : error C2673: 'setUserName' : global functions do not have 'this' pointers
      1>.\username_password.cpp(57) : error C2227: left of '->username' must point to class/struct/union/generic type
      1>password_window.cpp
      1>.\password_window.cpp(13) : error C2061: syntax error : identifier 'username_password'
      1>.\password_window.cpp(29) : warning C4312: 'type cast' : conversion from 'LONG' to 'connection *' of greater size
      1>.\password_window.cpp(34) : warning C4244: '=' : conversion from 'wchar_t' to 'char', possible loss of data
      1>.\password_window.cpp(38) : warning C4800: 'char' : forcing value to bool 'true' or 'false' (performance warning)
      1>.\password_window.cpp(41) : error C2065: 'up' : undeclared identifier
      1>.\password_window.cpp(41) : error C2227: left of '->setPassword' must point to class/struct/union/generic type
      1>        type is ''unknown-type''
      1>.\password_window.cpp(42) : error C2227: left of '->setPortAddress' must point to class/struct/union/generic type
      1>        type is ''unknown-type''
      1>.\password_window.cpp(43) : error C2227: left of '->setServerAddress' must point to class/struct/union/generic type
      1>        type is ''unknown-type''
      1>.\password_window.cpp(44) : error C2227: left of '->setUserName' must point to class/struct/union/generic type
      1>        type is ''unknown-type''
      1>.\password_window.cpp(46) : warning C4244: '=' : conversion from 'wchar_t' to 'char', possible loss of data
      1>.\password_window.cpp(52) : warning C4800: 'char' : forcing value to bool 'true' or 'false' (performance warning)
      1>.\password_window.cpp(73) : warning C4800: 'ATOM' : forcing value to bool 'true' or 'false' (performance warning)
      1>.\password_window.cpp(147) : warning C4311: 'type cast' : pointer truncation from 'connection *' to 'LONG'
      1>.\password_window.cpp(160) : warning C4311: 'type cast' : pointer truncation from 'connection *' to 'LONG'
      1>mysql_manager.cpp
      1>Build log was saved at "file://c:\Users\johny\Desktop\softback\vc\mysql_manager\mysql_manager\Release\BuildLog.htm"
      1>mysql_manager - 34 error(s), 10 warning(s)
      ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        It is because of your use of pre-compiled headers only for the release build. The debug build does not use pre-compiled headers.

        When you do use pre-compiled headers then the pre-compiled headers must be the first thing included in the file. My Visual Studio (2008 which is newer than yours) emits this warning

        Code:
        1>.\username_password.cpp(1) : warning C4627: '#include "username_password.h"': skipped when looking for precompiled header use
        1>        Add directive to 'stdafx.h' or rebuild precompiled header
        Which hints at it, in username_passwo rd.cpp at the top you have

        Code:
        #include "username_password.h"
        #include "stdafx.h"
        You need to reverse the order that the headers are included to

        Code:
        #include "stdafx.h"
        #include "username_password.h"
        You have the same issue in password_window .cpp.

        Also these 2 warnings

        Code:
        1>.\username_password.cpp(17) : warning C4172: returning address of local variable or temporary
        1>.\username_password.cpp(24) : warning C4172: returning address of local variable or temporary
        Are indicative of a serious error in your program, you need to fix them.

        Comment

        • johny10151981
          Top Contributor
          • Jan 2010
          • 1059

          #5
          Hi,
          Thanks it worked. But I think I would have think a little more to understand why it act like that.

          order of file including. never faced it before,

          Thank you very much.
          Best Regards,
          Johny

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            It's all to do with pre-compiled headers. Normally order of header inclusion does not matter, except for making sure things used in 1 header have already been included.

            However with pre-compiled headers the compiler has run over just the headers in a specific file, or order to use the output of the pre-compilation all the other files must start with the same headers otherwise it doesn't work.

            BTW in such a small project I would just switch off pre-compiled headers it just confuses the build process.

            However in a project with a large number of files it is worth using because it can have a significant effect on the amount of time it takes to build the project.

            Comment

            • johny10151981
              Top Contributor
              • Jan 2010
              • 1059

              #7
              HI,
              I understand your point completely.

              By the way. The tab focusing problem is still in there. If someone can help...

              Comment

              Working...