mkulke/ftplibpp

not really an issue

mohamed--abdel-maksoud opened this issue · 1 comments

First, thanks for the excellent library. I just wonder why in the sample program you use "new" instead of instantiating the class directly, i.e.

    ftplib ftp;
    ftp.Connect(config().host.c_str());
    int loggedin = ftp.Login(config().username.c_str(), password.c_str());
    ftp.Quit();

Thanks, your code allocates the object on the stack, which means it is cleaned up, when „ftp“ goes out of scope. This is perfectly fine in many scenarios (you should prefer it to allocation with „new" wherever possible). However when you need the object outside of the scope in which it was created, you need to use „new“ to put the object on the heap, and free the space using „delete" when it’s not needed any more.

Am 22.01.2015 um 16:43 schrieb Mohamed Abdel Maksoud notifications@github.com:

First, thanks for the excellent library. I just wonder why in the sample program you use "new" instead of instantiating the class directly, i.e.

ftplib ftp;
ftp.Connect(config().host.c_str());
int loggedin = ftp.Login(config().username.c_str(), password.c_str());
ftp.Quit();


Reply to this email directly or view it on GitHub #4.