Solved

root namespace

Posted on 2006-07-13
3
460 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 500 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 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