├── README.md
├── TrollLanguage
│ ├── TokenParser.cpp
│ ├── TokenParser.hpp
│ └── main.cpp
#include <iostream>
#include "TokenParser.hpp"
int main(int argc, const char * argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
TokenParser *tokenParser = new TokenParser();
tokenParser->TestFunc();
return 0;
}
#include "TokenParser.hpp"
void TestFunc() {
std::cout << "can u see me?";
}
enter code here
#ifndef TokenParser_hpp
#define TokenParser_hpp
#include <iostream>
class TokenParser {
public:
void TestFunc();
};
#endif /* TokenParser_hpp */
Hello, World!
can u see me?
Apple Mach-O Linker (Id) Error
"TokenParser::TestFunc()", referenced from:
Linker command failed with exit code 1(use -v to see invocation
答案 0 :(得分:1)
您需要在实现文件中将类名作为函数定义的一部分。就目前而言,您正在定义一个名为TestFunc
的免费功能。
#include "TokenParser.hpp"
void TokenParser::TestFunc() {
std::cout << "can u see me?";
}