15,906,625 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 2246366 (Top 8 by date)
Member 2246366
7-Dec-11 11:52am
View
thanks a lot!! That's the solution. Will take a while to understand it. But I can go on.
Member 2246366
7-Dec-11 11:47am
View
Entered the [] brackets. But that doesn't solve the problem.
And the problem is really that the vector's last item is deleted. I put a breakpoint into the desctructor an erase() calls the destructor of the instance containing i = 4 and pStr = "4". No other destructor is called
Member 2246366
7-Dec-11 11:39am
View
replaced the last lines:
vctc.erase(vctc.begin());
char * pShouldNotHaveBeenDeleted = vctc[3].pStr;
still the same: vctc[3].pStr is somewhere in nirvana
It really has been deleted!
Forgot to mention that the app crashes when it leaves TestVectorErase(). The vector tries to delete it's items and fails to delete the last item
Member 2246366
7-Dec-11 11:06am
View
ok, but to write it clear
I get
vctc[0].pStr is "1"
vctc[1].pStr is "2"
vctc[2].pStr is "3"
vctc[3].pStr is undefined, deleted ...
Member 2246366
7-Dec-11 11:01am
View
isn't this the same:
c(const c & other)
{
pStr = 0;
SetI(other.i);
}
Member 2246366
7-Dec-11 10:59am
View
Hi Jack,
that's how I supposed it would work. But erase really deletes the 5th element. The instances' member strings contain "1", "2", "3" and something bad.
Cheers,
Thomas
Member 2246366
7-Dec-11 10:54am
View
Hi Jack,
can you tell me what's wrong with my copy constructor?
Or give me a working one ;)
Best Regards,
Thomas
Member 2246366
7-Dec-11 10:51am
View
Thanks for the quick comment.
Of course cinst is gone after the for loop. But as far as I understand push_back it creates copies of the instance using the copy constructor.
Show More