Hi,
Is it possible to have a class level namespace opening instead of
file level .
Something like this,
I have a long namespace like
namespace com { namespace my_company{ namespace my_project{ namespace
parser{
class my_parser{
};
}}}}
Now when I want to use this , I usually make a shortcut and use it,
with the assumption that I am working at my_project level, thus no
name resolution at that level is needed.
thus in the file,
namespace parser = com::my_company ::my_project::p arser;
Thus it is in the file scope.
Then use it as parser::my_pars er in the header;
The same thing also can be done at function scope.
However, how this can be done in the class scope ?
like,
class my_parser_usage {
namespace parser = com::my_company ::my_project::p arser;
public:
parser::my_pars er get_pasrer()con st;
}
class my_second_parse r_usage{
namespace parser = com::my_company ::my_project::p arser2;
public:
parser::my_pars er get_pasrer()con st;
}
Thanks
abir 1 1525
On 8 Feb 2007 22:41:57 -0800, "toton" <ab*******@gmai l.comwrote:
>Hi,
Is it possible to have a class level namespace opening instead of file level .
Something like this, I have a long namespace like namespace com { namespace my_company{ namespace my_project{ namespace parser{
class my_parser{
}; }}}}
Now when I want to use this , I usually make a shortcut and use it, with the assumption that I am working at my_project level, thus no name resolution at that level is needed.
thus in the file,
namespace parser = com::my_company ::my_project::p arser;
Thus it is in the file scope.
Then use it as parser::my_pars er in the header; The same thing also can be done at function scope.
However, how this can be done in the class scope ? like,
class my_parser_usage {
namespace parser = com::my_company ::my_project::p arser; public:
parser::my_pars er get_pasrer()con st; } class my_second_parse r_usage{
namespace parser = com::my_company ::my_project::p arser2; public:
parser::my_pars er get_pasrer()con st; }
Thanks abir
Not exactly, but you can pull in symbols from another namespace:
class my_parser_usage {
typedef com::my_company ::my_project::p arser parser;
public:
parser get_parser() const;
};
-dr This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Anonymous |
last post by:
Is namespace the same thing as scope? While reading the book
"Thinking in C++", I was under the impression that namespace is, well,
a namespace--a feature to create a hiearchy for identifiers within the
Global Namespace. And that, all identifiers within a given namespace,
however deeply nested they are, each of them has the Global Scope.
So, if
namespace outer {
int a = 1;
|
by: John L. Clark |
last post by:
I am curious as to the rationale, and effect, of having default
namespaces not applying (directly) to attributes (see
http://www.w3.org/TR/REC-xml-names/#defaulting). Given an attribute
without a namespace prefix, what is its namespace, if default
namespaces do not apply? Are (either of) prefixed or non-prefixed
attributes correct? For example, are the following equivalent:
<html:br class="foo"...
|
by: Wole Ogunremi |
last post by:
Sorry if this is a bit elementary...
If a namespace contains another namespace, and a class with the same names
how can one differentiate them?
Eg
Namespace foo
Class doSomething
........
End Class
|
by: clinton__bill |
last post by:
Hi,
I usually use "using namespace <namespace_name>" to reference a
namespace. Today I run across a code, in its header file it has this,
namespace SP1{
class C1;
}
While SP1::C1 is a namespace::class declared and defined somewhere
else. It seems the above 3 lines is similar to "using namespace SP1;",
|
by: Mike Oliszewski |
last post by:
Given the following c# code:
namespace Company2
{
public class SomeFunctions
{
public void FunctionA()
{
// Do Something.
}
| |
by: Simon Edwards |
last post by:
Something thats been bugging me for a while...
how do you create a namespace that has many children (namespaces)
I.e system.io.blah.blah
Iv'e done it by creating a class which contains another class.
i can see the properties of the first class and the namespace of the second
(inner class) but can't see the properties of the 2nd....
|
by: Ruslan |
last post by:
Hi,
I have 3 projects:
1. Common
2. Desktop
|
by: Kevin Newman |
last post by:
The primary problem I've had with php is the lack of namespaces, which
makes OOP very difficult to organize, since you end up with large number
of classes cluttering up the same namespace - which leads to a secondary
problem involving php's __autoload feature. Since you cannot specify a
namespace when calling a class that may not have been included, you are
forced to store all of your classes in the same folder in your file
system. This...
|
by: toton |
last post by:
Hi,
I have two namespace contains class InkFrame and PrefDialog
respectively. PrefDialog needs InkFrame to show the dialog over the
frame. It also stores a pointer to InkFrame inside it.
Now I want InkFrame to be forward declared in the PrefDialog header
file rather than to be included. I want to include it in the cpp file
instead. There is no harm including it in PrefDialog header, and it
works. But I want to save some compilation time....
|
by: Peng Yu |
last post by:
Hi,
I'm wondering if there is something in namespace like the 'private'
keyword in class?
I want to define some class or function that can only be used within
that namespace.
Thanks,
Peng
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |