Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ garbage collection wtf?

Name: Anonymous 2007-09-11 1:06 ID:rtAr8p98

Heres some pseudo code of mine:

global vector
function{
    create class
    fill vector with class
}


The problem is after the function ends class gets destroyed. how do i make it so that class doesn't get deleted?

Name: Anonymous 2007-09-11 1:07 ID:rtAr8p98

note that class is full of pointers to class

Name: Anonymous 2007-09-11 1:09 ID:Gj3Zd7eB

You're probably making an object on the stack. Put it on the heap.

Name: Anonymous 2007-09-11 1:09 ID:Gj3Zd7eB

Also: C++ shitsux

Name: Anonymous 2007-09-11 1:29 ID:t+DgDrtZ

>>1
Try not making it a local variable.

Name: Anonymous 2007-09-11 1:38 ID:WAxu/Cpl

C++ stack collection lol?

Name: Anonymous 2007-09-11 2:04 ID:o/oj4UnD

ONE WORD, YOU'RE A FUCKING IDIOT, THREAD OVER

Name: LIMBUS TORBALDS 2007-09-11 2:05 ID:TqYTyDBt

YOU ARE RETARDED.

Name: Anonymous 2007-09-11 2:58 ID:KTl7OuYu

>>3
how do i do that?

Name: Anonymous 2007-09-11 3:00 ID:Heaven

>>9
Read K&R.

Name: Anonymous 2007-09-11 3:07 ID:/6x+Okl4

new

Name: Anonymous 2007-09-11 3:18 ID:B6YvpIY+

>>1
Read up on stack allocation, heap allocation and function scope. create class outside the function and pass into function as pointer or reference.

Name: Anonymous 2007-09-11 3:55 ID:t+DgDrtZ

>>9
malloc(), you moron.

Name: Anonymous 2007-09-11 4:16 ID:DNC6Qjrb

>>13
>>9
lawl, java programmers are educated stupid

Name: Anonymous 2007-09-11 5:40 ID:0JXBLwQ3

>>14
lawl

Name: Anonymous 2007-09-11 7:11 ID:Heaven

garbage collection
garbage collection != stack unwinding

Name: Anonymous 2007-09-11 7:52 ID:F6ZA516u

>>1
If you're passing instances of objects which were created on the stack to the vector, the vector will use the classes copy constructor to make a copy of it, hence it should work even after scope exits. If you're adding pointers to the vector, everyone was correct in calling you a moron, OP.

Name: Anonymous 2007-09-11 9:12 ID:ApL0SDln

>>16
Some niggers do it all in the stack and call that "garbage collection"

Name: Anonymous 2007-09-11 9:34 ID:a3awdsOA

>>18
It was a beatiful revelation to me when I discovered that recursive functions are the key to dynamically sized arrays.

Name: Anonymous 2007-09-11 9:37 ID:7xPyNuDe

>>19 They did that on Mythbusters

Name: Anonymous 2010-12-06 9:48

Back to /b/, ``GNAA Faggot''

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List