hi,
for terrible reasons my stdafx.h has:
using namepsace std;
in it. Now, how can I "un-use the namespace in a cpp file, that _must_
include this header?
--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%c gl%ssic%ccom%c" , "ma", 58, 'g', 64, "ba", 46, 10);} 6 2940
Gernot Frisch wrote: hi,
for terrible reasons my stdafx.h has: using namepsace std; in it. Now, how can I "un-use the namespace in a cpp file, that _must_ include this header?
You can't
That's one reason why using a 'using'-directive is a really
bad idea in a header file.
--
Karl Heinz Buchegger kb******@gascad .at
"Gernot Frisch" <Me@Privacy.net > skrev i en meddelelse
news:36******** *****@individua l.net... hi,
for terrible reasons my stdafx.h has: using namepsace std; in it. Now, how can I "un-use the namespace in a cpp file, that _must_ include this header?
Why not just remove that using directive? You might have to clean-up some
code, but it should not be that difficult and will give cleaner code
afterwards.
An alternative would be to properly qualify the call in the cpp-file.
/Peter -- -Gernot int main(int argc, char** argv) {printf ("%silto%c%cf%c gl%ssic%ccom%c" , "ma", 58, 'g', 64, "ba", 46, 10);}
Peter Koch Larsen wrote: "Gernot Frisch" <Me@Privacy.net > skrev i en meddelelse news:36******** *****@individua l.net... hi,
for terrible reasons my stdafx.h has: using namepsace std; in it. Now, how can I "un-use the namespace in a cpp file, that
_must_ include this header? Why not just remove that using directive? You might have to clean-up
some code, but it should not be that difficult and will give cleaner code afterwards. An alternative would be to properly qualify the call in the cpp-file.
stdafx.h is a implementation header for Visual Studio and maybe other
inplementations , so I wouldn't recommend changing it. However,
searching my VS6.0 files doesn't find a using statement in stdafx.h.
I haven't found it necessary to use this, although it may be required
for MFC or other off-topic stuff. Many people include it reflexively
because certain help files seem to do so. The OP could try taking out
that header and just including the ones actually needed.
Brian
Karl Heinz Buchegger wrote: Gernot Frisch wrote:
hi,
for terrible reasons my stdafx.h has: using namepsace std; in it. Now, how can I "un-use the namespace in a cpp file, that _must_ include this header?
You can't That's one reason why using a 'using'-directive is a really bad idea in a header file.
and, further, I think that 'using' is just plain bad. Really, it is a band-aid
fix to lazy programmers and code clutter.
"Julie" <ju***@nospam.c om> wrote in message
news:oCtOd.2987 1$xt.24768@fed1 read07... and, further, I think that 'using' is just plain bad. Really, it is a band-aid fix to lazy programmers and code clutter.
Or for programmers who don't want to waste their time typing redundant
characters. What is the generally accepted idiom for these kinds of things?
OnceAndOnlyOnce : http://www.c2.com/cgi/wiki?OnceAndOnlyOnce. Maybe you
should say, "Three strikes and you 'using,'" that is, you can "use" a
namespace once you use it three or more times, but less than that is lazy.
- JFA1
Jordan Stewart schrieb: You could consider surrounding the #include directive with another namespace (if you don't consider that just as bad).
that doesn't work with a lot of headers because they use global scope
qualifiers:
struct A{
struct A{
::A *a;
}
}; This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: cppaddict |
last post by:
It is typical to put the line:
using namespace std;
at the top of a file which makes use of std library objects. To take
a simple example:
#include <iostream>
using namespace std;
|
by: Petter Reinholdtsen |
last post by:
I ran into a problem on HP-UX 11.00 the other day, where it refused to
compile a program using 'using namespace std;' at the top. The reason
seem to be that the compiler refuses to accept 'using namespace std;'
unless the std namespace was declared first.
This triggered my curiosity, and I tried to find out what the ANSI C++
standard had to say about this. I'm unable to find a conclusion, and
hope someone here have a clue to spare.
...
|
by: Pranav Shah |
last post by:
What is the differrence between using the "using" caluse outside of the
namespace definition and inside the namespace.
Example Outside:
using System;
namespace Example.Outside
{
}
|
by: Simon |
last post by:
I need call a LoginUser API from MC++ dll, but when I try to call the I have
always the same exception:
"System.NullReferenceException: Object reference not set to an instance of
an object.
at LogonUser(String lpszUsername, String lpszDomain, String lpszPassword,
Int32 dwLogonType, Int32 dwLogonProvider, IntPtr phToken)"
Thanks in advance
|
by: Brian Gideon |
last post by:
I stumbled across something odd today about the placement of the using
keyword. Section 9.3.2 of the C# v1.1 specification did not answer my
question. My confusion is isolated to what happens in File1.cs of the
following code. Notice that when the using keyword is placed outside
of the namespace decleration its behavior is different than placing it
inside the namespace decleration.
Questions:
1) Section 9.3.2 of the specification...
| |
by: acb |
last post by:
Hi,
I wrote a DLL Component (using Visual Studio 2005) and managed to
include it into a C# Console application.
I am now trying to include this component into a Web project. I copy
the DLL into the bin directory but am not able to progress. Can anyone
please guide me to an online tutorial on the subject.
Thanks,
|
by: Keith Patrick |
last post by:
Can someone tell me the difference in terms of actual implications using:
namespace MyNamespace {
using System;
class MyClass {...}
}
vs.
using System;
|
by: Pep |
last post by:
Is it best to include the code "using namespace std;" in the source or
should each keyword in the std namespace be qualified by the namespace tag,
such as
std::cout << "using std namespace" << std::endl;
Myself I am not sure which I prefer, it is certainly easier to specify that
the std namespace is being used instead of tagging each member of the
namespace?
|
by: Wayne Shu |
last post by:
When I read the chapter of the namespace of the book C++ Primer(3e).
It explain the using directive as follow:
"A using directive makes the namespace member names visible as if they
were declared outside the namespace at the location where the namespace
definition is located."
I have some doubt about the using directives for the nested namespace,
so I wrote a program to test it,
#include <iostream>
|
by: lewisms |
last post by:
Hello all,
I am quite new to c++/. Net so please don't shoot me down for being a newbie. Any way I am trying to make a simple multithreading program that is just to learn the ideas behind it (before I incorporate them in another program). I just can’t seem to get a non-static call to work in my thread that has access to the Form1 variables and controls I need. I can call a non-static function using another class but then I can seem to get in...
|
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: 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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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...
| |