lua_pushcfunction (lua 5.2 사용)을 사용하려고합니다. 나는 구조체 내가 lua_pushcfunction(lua_state, hand.readAll)
를 사용하고 error: argument of type 'int (readFunctions::)(lua_State*)' does not match 'lua_CFunction {aka int (*)(lua_State*)}'|
C++ 클래스에있는 함수를 다른 함수에 전달
가 어떻게 함수에 클래스에서 메소드를 통과 할 수
class readFunctions {
private:
std::ifstream file;
public:
static int readAll(lua_State*);
};
int readFunctions::readAll(lua_State *L){
std::string line;
std::string nam;
while (std::getline(file, line)) {
nam = nam + line;
}
std::cout << nam;
return 1;
}
readFunctions hand;
있나요?
나는 그 사실을 잊어 버렸습니다. 정적 인 경우 파일에 액세스 할 수 없습니다. 정적으로 만들지 않고도 할 수있는 방법이 있습니까? – user3103398
@ user3103398 업데이트 됨 – Schollii