프로그래밍/Lua
[Lua] 루아 - 자료형
QA Engineer - P군
2016. 1. 27. 15:47
반응형
루아에는 특별한 자료형이 없습니다.
#LUA
str = "문자열 입니다.";
number = 100;
boolValue = false;
print(str);
print(number);
print(boolValue);
#C++
string str = "문자열 입니다.";
int number = 100;
bool value = false;
cout << str << endl;
printf(number);
[결과]
문자열 입니다.
100
false
적당한 비유가 될지 모르겠지만 템플릿 변수 정도로 생각하면 될 것 같습니다.
어떠한 종류의 자료든지 가능하니까요.
#LUA
function textOut(arg1)
print(arg1);
end
pFunc = textOut;
pFunc("hello! wolrd!");
#include <iostream>
#include <string>
using namespace std;
void textout (string str)
{
cout << str << endl;
}
void main(void)
{
void(*pFunc)(string);
pFunc = textout;
pFunc("hello! wolrd!");
}
[결과]
hello! wolrd!
위와 같이 함수 포인터(포인터라는 개념과는 좀 다르겠지만)로 사용이 가능합니다.
반응형