Quantcast
Channel: User Peter - Reinstate Monica - Stack Overflow
Viewing all articles
Browse latest Browse all 223

Comment by Peter - Reinstate Monica on Copy Assignment Operator with Dynamically Allocated Vector

$
0
0
while data_ptr is (presumably) a pointer to a (single) int, that int is actually the first element in an array. You need to allocate the entire array with data_ptr = new int[v.capacity]; and then memcpy the first n_elements elements over.

Viewing all articles
Browse latest Browse all 223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>