how to link header files in c++
<p>Hi 
iam new to write programs in c++ by using header files and including them.</p>

<pre><code>//a.h
#ifndef a_H
#define a_H
namespace hello
{
  class A
  {
    int a;
    public:
      void setA(int x);
      int getA();
  };
} 
#endif

//a.cpp
#include "a.h"
namespace hello
{
   A::setA(int x)
  {
    a=x;
  }
  int A::getA()
  {
    return a;
  }
}

//ex2.cpp
#include "a.h"
#include&lt;iostream&gt;
using namespace std;

namespace hello
{
  A* a1;
}
using namespace hello;
int main()
{
  a1=new A();
  a1-&gt;setA(10);
  cout&lt;&lt;a1-&gt;getA();
  return 1;  
}
</code></pre>

<p>when i try to compile using g++ ex2.cpp
iam getting the following error</p>

<pre><code>In function `main':
ex2.cpp:(.text+0x33): undefined reference to `hello::A::setA(int)'
ex2.cpp:(.text+0x40): undefined reference to `hello::A::getA()'
collect2: ld returned 1 exit status
</code></pre>

<p>is there any other way to compile this
please any one help me</p>
