Visual C++ 2010 Express를 사용하고 있습니다. 버튼 (btn1
)과 레이블 (label1
)이 포함 된 양식 (Form1.h
)이 있습니다.다른 헤더 파일, Visual C++ 2010에서 레이블 텍스트를 변경 하시겠습니까?
단추를 클릭하면 다른 머리글 파일 (testing.h
)에서 함수를 호출하여 레이블의 텍스트를 변경합니다. 내가 가지고있는 것은이 같은 것입니다
...
Form1.h
#include "testing.h"
... standard form code generated by Visual Studio
private: System::Windows::Forms::Label^ label1;
...
private: System::Void btn1_Click(System::Object^ sender, System::EventArgs^ e) {
testfunc1();
}
};
testing.h 뭔가처럼
...
#ifndef _TESTING_FUNCS
#define _TESTING_FUNCS
void testfunc1(){
label1->Text = "Text has been changed from outside.";
}
#endif
내가 컴파일하려고 그것을 실행하면 에러 메시지가 나타나는데, 이는 'label1' is an undeclared identifier
(testing.h 내)이고 "left of '->Text' must point to class/struct/...
"을 참조하는 오류는
저는 C++을 처음 사용하고 Java를 사용하기 때문에 여기에 몇 가지 새로운 것들이 있습니다. ,
1) 어떻게 든 testing.h
헤더 파일에서 레이블을 액세스) 인수
2로 함수에 라벨을 통과 산세
을 참조하지만 난 : 나를 위해,이 두 가지 명백한 옵션은 어느 쪽을해야하는지 잘 모르겠다.
완벽한을, 감사합니다! – Birrel