Hello, and thanks for reading
I have been struggling with a memory corruption/crash that causes the message in the subject and humbly ask for your help.
I narrowed down the code to just a few lines hopefully it will be easy to see what is that I'm doing wrong.
Here is the main program
It seems that the crash occurs in the dst of the class Curve. Also, I noticed that it is called when the object "test" is pushed onto the vector. Should I create a copy constructor for the Curve class?
If anyone can offer some insight it would be much appreciated!
Thanks!
Thank you for your reply. I do understand the need for a copy constructor and overloaded = operator.
Sorry about having to ask again, but I'm having compilation issues with the copy function (algorithm) in VS2005.
Is #include <algorithm>
all I need?
If I include that file and don't define the std namespace then I get this:
error C3861: 'copy': identifier not found
If I say "using namespace std;" then my compiler yells that
1 2 3 4 5 6 7
c:\documents and settings\apertosa\my documents\visual studio 2005\projects\example\example\example.cpp(20) : error C2780: '`global namespace'::std::_Enable_if<!std::_Is_checked_iterator<_OutIt>::_Result,_OutIt>::_Result std::copy(_InIt,_InIt,_OutIt)' : expects 3 arguments - 2 provided
c:\program files\microsoft visual studio 8\vc\include\xutility(2370) : see declaration of 'std::copy'
c:\documents and settings\apertosa\my documents\visual studio 2005\projects\example\example\example.cpp(20) : error C2780: '_OutElem *std::copy(_InIt,_InIt,_OutElem (&)[_Size])' : expects 3 arguments - 2 provided
c:\program files\microsoft visual studio 8\vc\include\xutility(2362) : see declaration of 'std::copy'
c:\documents and settings\apertosa\my documents\visual studio 2005\projects\example\example\example.cpp(20) : error C2780: '`global namespace'::std::_Enable_if<std::_Is_checked_iterator<_OutIt>::_Result,_OutIt>::_Result std::copy(_InIt,_InIt,_OutIt)' : expects 3 arguments - 2 provided
c:\program files\microsoft visual studio 8\vc\include\xutility(2354) : see declaration of 'std::copy'
The std:: is so you don't have to say 'using namespace std', and the copy algorithm copies from curve.m_x to m_x.
Sorry about that! (That was really dumb of me!) :-S
[edit] BTW, you can always go to the homepage of this site and in the search bar type things like
algorithm::copy
and usually the very first link found is the documentation for it. (The only thing cplusplus.com seems to lack is documentation on the <functional> library...)