Pobranie wartości z klasy do Form1

0

Witam, mam za zadanie stworzyć grę RPG z interfejsem okienkowym. Mam klasę player, która dziedziczy po klasie character.
W Form1 chcę wyświetlić przykładowo poziom postaci:

// 
			// Level
			// 
			this->Level->AutoSize = true;
			this->Level->Location = System::Drawing::Point(13, 13);
			this->Level->Name = L"Level";
			this->Level->Size = System::Drawing::Size(39, 13);
			this->Level->TabIndex = 0;
			this->Level->Text = L"Level: "+player.lvl; 

lecz nie rozpoznaje klasy player. Domyślam się, że gdzieś muszę powiązać Form1 z tą klasą, ale zwykły include nie wystarcza.
Co zrobić?

0
  1. jaki błąd?
  2. przypadkiem nie próbujesz użyć nazwy klasy zamiast utworzyć obiektu tej klasy?
0

W form 1 tworzę:

player p = gcnew player();

Dalej w labelu o nazwie Level mam:

this->Level->Text = L"Level: "+p.lvl; 

Wyskakuje mi:

1>c:\users\grother\documents\obiektowe\rpgv3\rpgv3\Form1.h(64): error C2065: 'p' : undeclared identifier
1>c:\users\grother\documents\obiektowe\rpgv3\rpgv3\Form1.h(64): error C2228: left of '.lvl' must have class/struct/union

Plik player.h wygląda tak:

ref class player : public character
{
public:
	int lvl, exp, str, agi, spd, vit;
	player(void);
	player(const player^ p)
             {
                  lvl=p->lvl;
                  exp=p->exp;
             };
2
player ^p=gcnew player();
this->Level->Text = L"Level: "+p->lvl;
0

Dziwne poruszenie na forum. Sesja się zaczęła?

0
  1. nie twórz zmiennej o tej samej nazwie co nazwa klasy (możesz zrobić Player player ale nie rób player player.
  2. nie widzę powodu, by player było ref class.
  3. jaki sens ma ten konstruktor kopiujący?

1 użytkowników online, w tym zalogowanych: 0, gości: 1