|
...
void _Insert_n(iterator _Where, size_type _Count, const _Ty& _Val)
{
_Ty _Tmp = _Val;
size_type _Capacity = capacity();
...
It seems that the compiler could not find the operator=, but a copy constructor and the operator= have been present in the header <memory>:
template<class _Ty>
class auto_ptr
{
public:
typedef _Ty element_type;
explicit auto_ptr(_Ty *_Ptr = 0) _THROW0()
: _Myptr(_Ptr)
{
}
auto_ptr(auto_ptr<_Ty>& _Right) _THROW0()
: _Myptr(_Right.release())
{
}
auto_ptr(auto_ptr_ref<_Ty> _Right) _THROW0()
: _Myptr(_Right._Ref.release())
{
}
...
auto_ptr<_Ty>& operator=(auto_ptr<_Ty>& _Right) _THROW0()
{
reset(_Right.release());
return (*this);
}
...
The compiler just ignored them.
-------------
You don't know what you've got till it's gone.
|
|
|
|
|
Did you read the posting of Stuart to this topic?
It is nearly impossible to use auto_ptr in STL containers (and any other kind of container), because you run into a bunch of problems
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
Noooo - not quite. If you look at the vector definition, void _Insert_n(iterator _Where, size_type _Count, const _Ty& _Val) , it takes a const reference. BUT - in auto_ptr , none of the assignment operators/coy constructors take a const reference parameter. As you cannot implicitly convert const to non-const, the compiler cannot use these operators! It is that simple really, honest!
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Futher to my other replies - if you want to use smart pointers in STL containers, I'd suggest you use the Boost shared_ptr class. Go to www.boost.org[^]. There's a download for the whole library there. There's a whole lot more than just smart pointers as well...
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
You know this code will crash and burn?
Don't ever use auto_ptr in collections. Have a look at some other pointer type such as shared_ptr from the BOOST library.
|
|
|
|
|
I have a CDialog based app, and I need to check restart/shutdown of the system. I should ask an user with confirmation, before closing app ( when presented the active threads ).
Why WM_QUERYENDSESSION in PreTranslate does not work?
Pavel Sokolov,
CEZEO software,
LanTalk Network,
http://www.cezeo.com
http://www.lantalk.net
|
|
|
|
|
I don't quite understand what you are asking, but if you want to restart or shutdown Windows, call ExitWindowEx().
_____________________
"They'd dearly make us pay
For laughing in their faces
And making it our way"
-Love My Way, Psychedelic Furs
|
|
|
|
|
I have tired to catch WM_QWERYENDSESSION in the PreTranslateMsg but this is not work. I found the right way, afx_msg OnQweryEndSession() ...
Pavel Sokolov,
CEZEO software,
LanTalk Network,
http://www.cezeo.com
http://www.lantalk.net
|
|
|
|
|
Hi,
I have to show a nicely formatted document with some text, lines, tables, possible pics and graphs from ActiveX controls in my app.
Could somebody please give me a pointer? Maybe some libraries?
Thanks
R.
|
|
|
|
|
I am reading "Introduction to MFC Programming with Visual C++" by Richard M. Jones. I am new to MFC and Win 32, and Visual Studio, but am otherwise a proficient and experienced programmer.
I am trying the second example from the book and it is not working as expected. Instead of a string as output all I get is integer (probably the memory address of the CString object).
#include <afx.h><br />
<br />
#include <iostream>
using namespace std;
<br />
int main()<br />
{<br />
CString s;<br />
CString sa("Strings ");<br />
CString sb = CString("are easy ");<br />
CString sc = "in MFC!";<br />
s = sa + sb + sc + '!';<br />
cout << s;<br />
<br />
::Sleep(2000);
return 0;<br />
}
As specified in the book I created a Win 32 Console App then specified "Use MFC in a shared DLL" and then built it in debug mode. I tried this with both 6.0 and .NET. The book is suposed to cover 6.0.
What is going wrong?
PS I changed the code to
cout << s.GetString();
Which works, is the book simply mistaken, out of date (it claims to cover 6.0) or am I configuring the project wrong in some way?
|
|
|
|
|
Maybe cout does not recognize a CString object.
-----
CString szText = "Testing 1 2 3";
cout << static_cast<pctstr>(szText);
-----
Kuphryn
|
|
|
|
|
You've got it in one - you need to cast it to a const char *, or get the underlying char * using a method as you have done. Or you could write an iostream inserter for CString. I have articles on CP to show you how.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Good day all, new day, new help me please
in this function to return the users system directory
CString CSetupApp::GetSystemDir()
{
CString szSystemDir((char)0, MAX_PATH);
::GetSystemDirectory(szSystemDir.GetBuffer(0), MAX_PATH);
szSystemDir.TrimLeft();
szSystemDir.TrimRight();
return szSystemDir;
}
the dir is returned correct, but i can't trim the string to add
an apps filename
eg. CString m_Nfile;
m_Nfile = GetSytemDir();
m_Nfile += "\\app.exe";
AfxMessageBox(m_Nfile);
will return "c:\Winnt\system32" or whatever your flavour
with the .Trim having no effect
if anyone can shed some light, its always appreciated.
shotgun
|
|
|
|
|
You must call ReleaseBuffer() after a GetBuffer(), and before using any other CString methods that modify the string.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
thanks alot.
shotgun
|
|
|
|
|
Hi,
As a new beginner I would like to know that: Is it possible with Visual C++ MFC 6.0 I can install an Icon (ShortCut) that links to an application (.exe) in Run Time?
Let say I have:
a) c:\Trial_Application\Trial.exe
b) When I run my SetUp program application Visual C++ 6.0 MFC (Run Time), I would like to add at the user DeskTop an Icon ShortCut (might be the same Icon of the Trial.exe) to that Trial.exe
Some one know how to do that? I appreciate any help here!
Thanks
|
|
|
|
|
|
Hi,
I did try to do the codes, but it failed from the start: the if(SUCCEEDED(hres)) is not TRUE! I do not know why?
Even I try to get in (bypassing if) I get errors the next line (psl->SetDescription(description); ) ... I think I did not now how to use this function! Here what I called:
CreateFileShortcut("Hello","c:\\Try_Icon\\Release",
"c:\\Windows\\Desktop","IconInstallDlg.exe","Trial");
Because I have the c:\Try_Icon\Release\IconInstallDlg.exe & I would like to add an Icon on My Window Desktop ... do you my errors by calling like that?
Would you please to point out what were wrong, I am only the new Visual C++ programmer!
Many thanks,
|
|
|
|
|
Hi all,
I have a dialog that pops up every hour or so, and I'd like it to return to the previous active window after the user clicks OK on the dialog.
I've got a HWND member variable that gets the previous active window in PreCreateWindow, and a SetActiveWindow function in the PostNcDestroy of the popup dialog class. I'm not sure about where else to put these functions, --and it does bomb with an error, "...memory could not be read."
Could someone point me in the right direction? Where's the best place to do this?
Thanks in advance.
Matt
|
|
|
|
|
Found that
::SetForegroundWindow(hwnd); seems to work. Just didn't look deep enough.
Sometimes things are staring you right in the face and you don't even realize it.
Matt
|
|
|
|
|
Hi,
As a new beginner I would like to know that: Is it possible with Visual C++ MFC 6.0 I can install an Icon (ShortCut) that links to an application (.exe) in Run Time?
Let say I have:
a) c:\Trial_Application\Trial.exe
b) When I run my SetUp program application Visual C++ 6.0 MFC (at Run Time), I would like to add at the user DeskTop an Icon ShortCut (might be the same Icon of the Trial.exe) to that Trial.exe
Some one know how to do that? I appreciate any help here!
Thanks
|
|
|
|
|
This is how I would attempt to do it:
First open up a simple shortcut in notepad. Figure out the way a shortcut works and learn how to formulate one linking to your program(its fairly easy to understand whats going on)
Now in the setup program write a file to the path C:\Windows\Desktop with the extension *.lnk
That should be it
-Ken Mazaika
|
|
|
|
|
I already read a book on Win32 api programming and now I want to learn MFC.
I started reading "Teach Yourself Visual C++.Net in 21 Days" but it seemed that all I was doing was learning how to modify and the code generated my the App Wizzards.
So now I am reading "Introduction to MFC Programming with Visual C++" which devotes several chapters to covering the inner working of MFC so that when I create my first MFC app I will actually be able to read and understand the code that is gennerated. One I know the basics I will likely switch back to the Teach Yourself book. Unfortunately this book only covers Visual C++ 6.0 and I am using Visual C++ .Net.
My Questions are
1) How different is 6.0 and .NET? I am not overly concerned with changes to Visual Studios User interface. Even thought the direction give instructions for 6.0 I can still figure out how to do it in .NET. Nor am I concerned with changes with the various Wizzards. I am only worried about changes to MFC classes between versions.
2) Do you know of any up to date book that teaches the fundamentals first and the wizzards second?
3) Would I be better off reading online documents at MSDN libarary?
Thanks for your advice - Rask
|
|
|
|
|
You read a book (good start!) but do you understand how to use the APIs? You absolutely must* be proficient in programming at the API level before starting with MFC.
*I know, someone else will come along and say, "No you don't!" but you do.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I understand how to use the APIs. In addition to reading the book and typing in the examples I spent considerable time experimenting with the source code from the book. I also make it a point whenever reading a book to write a simple application every three or four chapters that put into practice what I learned.
I also have a BS in CIS and have been programming in C/C++ for at least six years (mostly comand line stuff though).
|
|
|
|