Hello I have a simple program with a main.cpp
an a.h
and an a.cpp
. I'd like to define a class in a.cpp and simply call on the method of the class in main.cpp
my a.h
:
#include <iostream>
using namespace std;
class Hello
{
string hello();
};
my a.cpp
#include "a.h"
#include <iostream>
string class Hello::hello(){return "hello world";};
my main.cpp
#include "a.h"
int main()
{
Hello h;
cout << h.hello();
}
EDIT : changed the include"a.cpp"
to a.h
and added the string to the definition of the method hello. added the #include <string>
to a.h
while compiling I get the error
"a.cpp:4:22: error: ‘hello’ in ‘class Hello’ does not name a type string class Hello::hello() {return "Hello";};"
"a.cpp:4:28: error: expected unqualified-id before ‘)’ token string class Hello::hello() {return "Hello";};"