|
-
October 20th, 1999, 09:54 AM
#1
using auto_ptr (only)
I use the auto_ptr template class in my code in several places. I'd like to use it without the std:: qualifier so I have two choices: 1, bring in the whole std namespace with the using directive; or 2, bring in just the auto_ptr class with the using declaration.
My question is, what's the proper way to do the second option? I've tried doing this:
#include <memory>
using std::auto_ptr<class T>;
This compiles fine but then when I say:
auto_ptr<CFile> pFile;
the compiler tells me: 'auto_ptr' : undeclared identifier.
What am I doing wrong?
Thanks,
Alvaro
-
October 20th, 1999, 05:04 PM
#2
Re: using auto_ptr (only)
I'd like to know the answer too!
-
October 20th, 1999, 05:15 PM
#3
Re: using auto_ptr (only)
A using declaration brings in a name. It doesn't matter if the type is incomplete, or if the name is even a type.
You want:
#include <memory>
using std::auto_ptr;
auto_ptr<CWnd> pToWindow; // works
Later,
Chris Tracy
[email protected]
-
October 20th, 1999, 05:24 PM
#4
Re: using auto_ptr (only)
Hi Chris,
I tried it but the compiler complained on the using line saying:
error C2955: 'auto_ptr' : use of class template requires template argument list
Thanks for your response,
Alvaro
-
October 26th, 1999, 09:41 AM
#5
Re: using auto_ptr (only)
I hadn't seen that problem since VC5, so I suspect that the "correct" answer is to upgrade to VC6sp3.
Until then, I believe either:
using std::auto_ptr<CFile>
or
using namespace std;
should work.
Truth,
James
http://www.NJTheater.com
http://www.NJTheater.com/JamesCurran
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|