Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

LNK2001

Ostatnio zmodyfikowano 2015-03-20 16:37
Autor Wiadomość
TheReclif
Temat założony przez niniejszego użytkownika
LNK2001
» 2015-03-15 23:28:46
Witam!
Do rzeczy:
C/C++
class handlingClass
{
private:
    static inputClass * HInput;
    hwnd win = NULL;
    int width;
    int height;
    int showWnd;
    lpctstr winName;
    lpctstr winClassName;
    hinstance appInst = NULL;
    RECT rect;
   
public:
    handlingClass();
    handlingClass( lpctstr name, int w, int h );
    virtual ~handlingClass() { delete HInput; HInput = NULL; };
    hwnd * getWin() { return & win; };
    void showWindow( int wndShow );
    void mainInit( UINT style, hinstance instance, LPCSTR curFile = NULL, LPCSTR icoFile = NULL, LPCSTR menuName = NULL );
    void createWindow( lpctstr winName, int w, int h, DWORD style = WS_VISIBLE, DWORD exStyle = NULL );
    static LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam );
    void wndEnd();
};

handlingClass::handlingClass()
{
    win = NULL;
    width = 0;
    height = 0;
    winName = "NULL";
    HInput = new inputClass;
    HInput->init();
}

handlingClass::handlingClass( lpctstr name, int w, int h )
{
    this->width = w;
    this->height = h;
    this->winName = name;
    HInput = new inputClass;
    HInput->init();
}

LRESULT CALLBACK handlingClass::WndProc( HWND hwin, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch( msg )
    {
    case WM_KEYUP:
        HInput->keyUp(( unsigned int ) wParam );
        return 0;
    case WM_KEYDOWN:
        HInput->keyDown(( unsigned int ) wParam );
        return 0;
    case WM_DESTROY:
        //komunikat włącza się gdy naciśniemy na [x] w lewym górnym narożniku okna
        return 0;
    }
    return DefWindowProc( hwin, msg, wParam, lParam );
}
I inputClass:
C/C++
class inputClass
{
public:
    inputClass() { };
    ~inputClass() { };
   
    void init();
   
    void keyUp( unsigned int key );
    void keyDown( unsigned int key );
    bool isKeyDown( unsigned int key ) { return keyStat[ key ]; };
   
private:
    bool keyStat[ 256 ];
};

void inputClass::init()
{
    for( int i = 0; i < 256; i++ )
    {
        keyStat[ i ] = false;
    }
    return;
}

void inputClass::keyUp( unsigned int key )
{
    keyStat[ key ] = false;
}

void inputClass::keyDown( unsigned int key )
{
    keyStat[ key ] = true;
}

Błąd:

Error 1 error LNK2001: unresolved external symbol "private: static class System::inputClass * System::handlingClass::HInput" (?HInput@handlingClass@System@@0PAVinputClass@23@A) C:\Users\Projects\Coś\Source.obj

Z góry dziękuję za pomoc.
P-128508
michal11
» 2015-03-16 00:05:56
Nie includujesz inputClass w handlingClass.
P-128509
pekfos
» 2015-03-16 15:31:41
Zapewne po prostu nie masz definicji HInput.

Nie includujesz inputClass w handlingClass.
W jaki sposób to może mieć tu cokolwiek do rzeczy..?
P-128532
michal11
» 2015-03-16 15:44:14
@up

Klasie handlingClass brakuje definicji inputClass, można to naprawić includując plik z definicją inputClass do handlingClass .
P-128534
pekfos
» 2015-03-16 16:13:43
Klasie handlingClass brakuje definicji inputClass, można to naprawić includując plik z definicją inputClass do handlingClass .
Nie brakuje. Autor tematu podał definicje dwóch klas, a nie treść dwóch plików..
P-128547
TheReclif
Temat założony przez niniejszego użytkownika
» 2015-03-16 20:49:58
Zapomniałem dodać, że definicja inputClass znajduje się przed definicją handlingClass(czyli kod na końcu jest w rzeczywistości pierwszy).
P-128585
pekfos
» 2015-03-16 20:52:11
Zdefiniuj HInput.
P-128586
TheReclif
Temat założony przez niniejszego użytkownika
» 2015-03-16 22:40:50
Postanowiłem usunąć sprzed deklaracji HInput słowo kluczowe "static", aby występowały tylko błędy kompilacji, a nie linkera(je łatwiej się naprawia). Teraz są 2 błędy:

Error 1 error C2227: left of '->keyUp' must point to class/struct/union/generic type c:\Users\Projects\Coś\Source.cpp 284

Error 2 error C2227: left of '->keyDown' must point to class/struct/union/generic type c:\Users\Projects\Coś\Source.cpp 287

Są to linijki:
C/C++
HInput->keyUp(( unsigned int ) wParam ); //C2227 #1
return 0;
oraz
C/C++
HInput->keyDown(( unsigned int ) wParam ); //C2227 #2
return 0;
Chyba będzie prościej, ale cały czas nie wiem, jak się do tego zabrać.
P-128597
« 1 » 2
  Strona 1 z 2 Następna strona