By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,903 Members | 1,647 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,903 IT Pros & Developers. It's quick & easy.

namespace for a class

P: n/a
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::parser;

Thus it is in the file scope.
Then use it as parser::my_parser 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::parser;
public:
parser::my_parser get_pasrer()const;
}
class my_second_parser_usage{
namespace parser = com::my_company::my_project::parser2;
public:
parser::my_parser get_pasrer()const;
}

Thanks
abir

Feb 9 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 8 Feb 2007 22:41:57 -0800, "toton" <ab*******@gmail.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::parser;

Thus it is in the file scope.
Then use it as parser::my_parser 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::parser;
public:
parser::my_parser get_pasrer()const;
}
class my_second_parser_usage{
namespace parser = com::my_company::my_project::parser2;
public:
parser::my_parser get_pasrer()const;
}

Thanks
abir
Not exactly, but you can pull in symbols from another namespace:

class my_parser_usage {
typedef com::my_company::my_project::parser parser;
public:
parser get_parser() const;
};

-dr
Feb 9 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.