How to use global userdefined class object
<p>In Friend.h</p>

<pre><code>#ifndef FRIEND
#define FRIEND 
class Friend
{

public:
    static int i ;
    int j;
    Friend(void);
    ~Friend(void);
}frnd1;
#endif
</code></pre>

<p>In Friend.cpp</p>

<pre><code>#include "Friend.h"
int Friend::i = 9;
extern Friend frnd1;
Friend::Friend(void)
{
}

Friend::~Friend(void)
{
}
</code></pre>

<p>In main.cpp</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;
#include"Friend.h"

int main()
{
frnd1.j = 9;
cout&lt;&lt;"hello";
getchar();
return 0;
}
</code></pre>

<p>When I run the above code, its gives the following linker error: </p>

<pre><code>error LNK2005: "class Friend frnd1" (?frnd1@@3VFriend@@A) already defined in main.obj
</code></pre>

<p>I am unable to understand how to use the global object in main function.</p>
