linkage prob...

Itay 'z9u2K' Duvdevani z9u2k@bezeqint.net
Fri Jan 3 16:46:00 GMT 2003


Hey,
I need an "extern static const" decleration, but it is forbidden...
at the moment, my app won't link...

summery:

decl.h:
namespace a
{
    namespace b
    {
        class x;
        // ...
    }
   
    using namespace b;
    // ...
}

*********

x.h:
#include "decl.h"
class a::b::x
{
public:
    // ...
    static const int q1;
};

**********

x .cpp:
#include "x.h"
const int a::b::x::q1 = 4;
// ...

********

main.cpp:
#include "decl.h"
#include "x.h"
#include <iostream>
using namespace a;

int main()
{
    std::cout << x::q1;        // will not link... g++ says:
    // main.cpp:8: undefined reference to `a::b::x::q1[in-charge](int 
const&)'
}

What am I doing wrong?
thanks...



More information about the Gcc-help mailing list