?
Solved

root namespace

Posted on 2006-07-13
3
Medium Priority
?
465 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 17098169
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
ID: 17106066
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 2000 total points
ID: 17106090
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

719 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