Solved

root namespace

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

786 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