What sort of errors are you getting? The following test program compiles and runs just fine, both under Visual C++ and g++.
#include <stdio.h>
namespace ns1
{
class c1
{
public:
c1() { printf("c1()\n"); };
~c1() { printf("~c1()\n"); };
};
typedef c1 *c1ptr;
};
int main(int argc, char* argv[])
{
printf("enter main()\n");
ns1::c1ptr p;
{
p = new ns1::c1();
delete p;
}
printf("exit main()\n");
return 0;
}
Edit: Another version, probably closer to what you are doing (one namespace invoking another):
#include <stdio.h>
namespace ns1
{
class c1
{
public:
c1() { printf("c1()\n"); };
~c1() { printf("~c1()\n"); };
};
typedef c1 *c1ptr;
};
namespace ns2
{
class c2
{
public:
c2() { printf("c2()\n"); };
~c2() { printf("~c2()\n"); };
void Initialize();
ns1::c1ptr p1;
};
typedef c2 *c2ptr;
};
void ns2::c2::Initialize()
{
printf("c2::Initialize()\n");
p1 = new ns1::c1();
delete p1;
}
int main(int argc, char* argv[])
{
printf("enter main()\n");
ns2::c2ptr p2;
{
p2 = new ns2::c2();
p2->Initialize();
delete p2;
}
printf("exit main()\n");
return 0;
}