I'm beginner in C++ and trying to run some starter code. I have the following files,
myTest.h
////////
#ifndef __myTest_h__
#define __myTest_h__
#include <string>
using std::string;
class myTest{
public:
int main(int, char const**);
};
#endif // __myArray_h__
myTest.cpp
//////////
#include<iostream>
#include<string>
#include "myTest.h"
using namespace std;
int myTest::main(int argc, char const *argv[])
{
std::cout<< "Hello World/n";
return 0;
}
When I try to run from the terminal in Mac OS using the command g++ myTest.cpp -o myTest.out
, I get the following error in the terminal,
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How to correct the code to getting started with C++? I can provide more info using the command -v
, please, let me know if that required.