I'm teaching myself how to use header files with .cpp files. I have been working on this issue for awhile and couldn't figure it out. Would anyone help me to address two errors? Thank you :)
driver.cpp
#include <cstdlib>
using namespace std;
#include "F.h"
#include "G.h"
int main()
{
FMMoore::hello();
GMMoore::hello();
system("pause");
return 0;
}
F.cpp
#include <iostream>
using std::cout;
#include "F.h"
namespace FMMoore
{
void hello()
{
cout << "hello from f.\n";
}
}
F.h
#ifndef F_H
#define F_H
namespace FMMoore
{
class FClass
{
public:
void hello();
};
}
#endif // F_H
G.cpp
#include <iostream>
using std::cout;
#include "G.h"
namespace GMMoore
{
void hello()
{
cout << "hello from g.\n";
}
}
G.h
#ifndef G_H
#define G_H
namespace GMMoore
{
class GClass
{
public:
void hello();
};
}
#endif // G_H
The errors are 'hello' is not a member of 'FMMoore' and 'GMMoore' has not been declared.
Also I have been checking spelling typo and other things. I don't know why it hasn't declared.