473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Thought you could do this?

#include <string>

class blah
{
public:

using namespace std;

string k;

};

int main()
{
blah j;
}
Why not?
-Tomás
Mar 1 '06 #1
5 1381
Tomás wrote:
#include <string>

class blah
{
public:

using namespace std;

string k;

};

int main()
{
blah j;
}
Why not?


Because the 'using' _directive_ shall not appear inside class scope.
See Standard, subclause 7.3.4 Using directive.

V
--
Please remove capital As from my address when replying by mail
Mar 1 '06 #2
Victor Bazarov posted:
Tomás wrote:
#include <string>

class blah
{
public:

using namespace std;

string k;

};

int main()
{
blah j;
}
Why not?


Because the 'using' _directive_ shall not appear inside class scope.
See Standard, subclause 7.3.4 Using directive.

V


So I there's the necessity to write the "std", as in:

#include <string>

class blah
{
public:

std::string k;

};
I'm writing code that takes a load of names from a particular namespace,
and so it would be handy to do what I originally intended.

-Tomás
Mar 1 '06 #3
Tomás wrote:
Victor Bazarov posted:
Tomás wrote:

Why not?


Because the 'using' _directive_ shall not appear inside class scope.
See Standard, subclause 7.3.4 Using directive.


So I there's the necessity to write the "std", as in:

#include <string>

class blah
{
public:

std::string k;

};
I'm writing code that takes a load of names from a particular namespace,
and so it would be handy to do what I originally intended.


If it's in a header file, fully qualify everything.

If it's in a source file, just take the directive outside of class scope.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Mar 1 '06 #4
> I'm writing code that takes a load of names from a particular namespace,
and so it would be handy to do what I originally intended.

-Tomás


Use typedef:

class A
{
private: typedef std::string string;

string a;

// ...
};

Regards,
Ben
Mar 2 '06 #5
benben posted:
I'm writing code that takes a load of names from a particular
namespace, and so it would be handy to do what I originally intended.

-Tomás


Use typedef:

class A
{
private: typedef std::string string;

string a;

// ...
};

Regards,
Ben

: )

-Tomás
Mar 2 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ron Adam | last post by:
With all the discussion about numbers here and particularly in regards to prePEP concerning decimal data types got me wondering about how numbers are handled when it comes to rounding. And if that...
100
by: Peter | last post by:
Company thought DB2 will be better than Oracle. The bottom line is when you do select, the system crash. I think it may take 4-5 years for DB2 to reach Oracle standard. Peter
116
by: Mike MacSween | last post by:
S**t for brains strikes again! Why did I do that? When I met the clients and at some point they vaguely asked whether eventually would it be possible to have some people who could read the data...
5
by: tHeRoBeRtMiTcHeLL | last post by:
Well, I think I have bitten off a little more than I can chew (at least all at once), and I'm only trying to hammer out tables/relationships at the design level. Which translates to "Seasoned...
22
by: Charles Law | last post by:
Could someone please explain to me, in words of one syllable or less, how I get the Validating event to fire for a form. I have a form with one text box, and two buttons: OK and Cancel. I have...
1
by: drclue | last post by:
I have a thought that I'm looking for some feedback on. I've created some infrastructure that works like googlemaps, and provides proxy services to a dedicated database , as well as facilities...
4
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of...
9
by: JT | last post by:
Here is the overall structure I will be referring to: End-program ProvideWorkFlow.dll Forms and methods that properly manipulate calls to methods in AccessUtils AccessUtils (a web service)...
3
by: DaTurk | last post by:
If I call this method, and pass it a byte by ref, and initialize another byte array, set the original equal to it, and then null the reference, why is the original byte array not null as well? I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.