dots in namespaces

  • Thread starter Thread starter PGP
  • Start date Start date
P

PGP

I am trying to work with some C# namespaces from managed c++. The namespaces
use a dot notation and generates a compiler error. Is there a way around
this?

#using "csharpassembly.dll"//has the namespace test and namespace
test.external under it.

void test()
{
test::test.external::class1* p = new test::test.external::class1()
;//error C2039- test is not a member of test.
}
 
I am trying to work with some C# namespaces from managed c++. The
namespaces
use a dot notation and generates a compiler error. Is there a way around
this?

#using "csharpassembly.dll"//has the namespace test and namespace
test.external under it.

void test()
{
test::test.external::class1* p = new test::test.external::class1()
;//error C2039- test is not a member of test.
}

dot notation is for C#.
for C++ you use :: like you would normally do.

notation has nothing to do with the namespaces themselves.
it is just a way of saying 'this namespace is a member of that namespace'

do it like this:
test::test::external::class1* p = new test::test::external::class1() ;

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
Bruno van Dooren said:
dot notation is for C#.
for C++ you use :: like you would normally do.

notation has nothing to do with the namespaces themselves.
it is just a way of saying 'this namespace is a member of that namespace'

do it like this:
test::test::external::class1* p = new test::test::external::class1() ;

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"

Bruno,
Thanks for the quick reply. That works.
 
Another question...

In C# a namespace declaration can use dots

namespace CompanyName.System.Foo {

How might one code this in C++?
 
mike said:
Another question...

In C# a namespace declaration can use dots

namespace CompanyName.System.Foo {

How might one code this in C++?

namespace CompanyName { namespace System { namespace Foo {
class Test {

};
}}}

I don't really know of a better way to accomplish this, but I'm open to
suggestions if anyone knows of a better solution.
 
Back
Top