I heard that Python has automated "garbage collection" , but C++ does not. What does that mean?

c++, garbage-collection, python

Solution

That means that python user doesn't need to clean his dynamic created objects, like you're obligated to do it in C/C++.

Example in C++:

char *ch = new char[100];
ch[0]='a';
ch[1]='b';
//....
// somewhere else in your program you need to release the alocated memory.
delete [] ch; 
// use *delete ch;* if you've initialized *ch with new char; 

in python:

def fun():
    a=[1, 2] #dynamic allocation
    a.append(3)
    return a[0]

python takes care about "a" object by itself.

Problem

I heard that Python has automated "garbage collection" , but C++ does not. What does that mean?

Original source