Reputation: 486
├── 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
Upvotes: 1
Views: 651
Reputation: 743
You need to prepend the class name as part of the function definition in the implementation file. As it stands, you're defining a free function called TestFunc
.
#include "TokenParser.hpp"
void TokenParser::TestFunc() {
std::cout << "can u see me?";
}
Upvotes: 1