cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
How to assing string value?
How to assing string value?
Aug 27, 2014 at 7:57pm UTC
TheBasix
(4)
I created my own list (template) and I want to assing string value, but I got error in file "SuperList.h" line 24. Why is that?
main.cpp
http://pastebin.com/Ap8hAvM6
SuperList.h
http://pastebin.com/fR2g41HF
Aug 27, 2014 at 8:11pm UTC
LB
(13399)
Looks like it compiles but crashes at runtime:
http://ideone.com/AEON4H
Aug 27, 2014 at 8:13pm UTC
TheBasix
(4)
Exactly, it cant assing string at line 24 inside SuperList.h.
But it works fine with int.
Aug 27, 2014 at 9:34pm UTC
Peter87
(11238)
In the constructor you forgot to initialize
capacity
and in the
add
function you allocate
cnt+2
elements instead of using
capacity
.
Topic archived. No new replies allowed.