开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
GCC 4.6.3
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
无
问题(Question):
怎么把 JavaScript 的程式码 , 改成 C++ ?
喂入的资料(Input):
无
预期的正确结果(Expected Output):
1
错误结果(Wrong Output):
main.cpp: In function 'int sub2()':
main.cpp:21:13: error: 'x' was not declared in this scope
cout << x <<endl;
^
程式码(Code):(请善用置底文网页, 记得排版)
JavaScript 原始码 (书本的范例,正确) => http://pastebin.com/pCgAwAym
C++ 原始码 (自己改写,错误) => https://repl.it/BafW/1
补充说明(Supplement):
用 Chrome 测试 JavaScript 原始码 会当掉
请用 IE 或 Firefox 来测试