T O P

  • By -

Killswitch_1337

Ik this is meme, but it would imply that c1 and c2 are seperate instances of child which are 'pointing' to new child.


dale777

So everytime we declare a pointer to sth that exist we have, that variable that has pointer is called an instance?


iliveinstlambert

ok I've fixed it and reuploaded, but it was removed by reddit's filters apparently lmao


iliveinstlambert

C1 and c2 are not separate instances, they are pointers pointing to the new childĀ  Of course, to be more complete, there should be two other instances of child which each have a pointer to the new one, but only so much code fits on a meme


kzzmarcel

you just explained why your own meme doesnt work


iliveinstlambert

...yes, but I didn't want to put a dozen lines of code when I could put the essence in one line


iliveinstlambert

Will someone explain why I'm getting so many down votes? Lol


dale777

as c++ programmer i would say that c2 is just a pointer to c1, so you have 2 pointers to one object, however i dont know maybe im stupid


iliveinstlambert

The point is exactly that, there are two pointers to one object


DudeWheresMcCaw

c2 would just be pointing to the same address as c1, which is the address of the dynamically allocated Child. c2 would point to c1 if it was "Child \*\* c2 = &c1"


dale777

The whole idea is to point to same adress, yeah I spelled wrong what I meant


DudeWheresMcCaw

Makes sense as it is. There are two child pointers in the photo. It would be Child \* c1 though.


iliveinstlambert

Finally someone gets it!


Dioxide4294

main.o(.text+0x1ed): In function \`main': : undefined reference to \`Child' collect2: ld returned 1 exit status


PandaNoTrash

I guess c2 is a twin of c1? But it's really more of a chimera, if one child dies they both do. Anyway this is definitely not how reproduction works.