root namespace

in vb.net there is possibility to set root namespace in project properties. Is there sth like this in c++/cli?
PLABBAsked:
Who is Participating?
 
AlexFMConnect With a Mentor Commented:
Yes, this is the way. Notice that you need to build this namespace hierarchy in h-files, and cpp files with implementation code can optionally contain line
#using namespace n1::n2;
0
 
AlexFMCommented:
VB files generated by Application Wizard don't contain namespace declaration. By default, root namespace is applied to every class in VB project. For example, root namespace = Test, and Form1.vb file looks like:

Public Class Form1
End Class

For client project, Form1 is actually Test.Form1.

C++ project explicitly defines namesapaces in h-files. When you create it, it's header files by default look like:

#pragma once

using namespace System;

namespace Test
{
    public ref class Class1
    {
    };
}

If you want to change namespace, you need to do this manually in the code.

Microsoft approach is to make life easy for VB developers and add more flexibility to C++ and C#.
0
 
PLABBAuthor Commented:
so to do nested namespaces the only way would be:

namespace n1
{
     namespace n2
     {
     }
}

any easier way?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.