Solved

root namespace

Posted on 2006-07-13
3
456 Views
Last Modified: 2008-01-09
in vb.net there is possibility to set root namespace in project properties. Is there sth like this in c++/cli?
0
Comment
Question by:PLABB
  • 2
3 Comments
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
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
 

Author Comment

by:PLABB
Comment Utility
so to do nested namespaces the only way would be:

namespace n1
{
     namespace n2
     {
     }
}

any easier way?
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
Comment Utility
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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now