[SOLVED] CS #include

$25

File Name: CS_#include.zip
File Size: 103.62 KB

5/5 - (1 vote)

#include

using namespace std;

class Foo{
public:
Foo(){
cout << “Foo’s constructor” << endl;}~Foo() {cout << “Foo’s destructor” << endl;}};int main(){if (1){Foo* fooPtr = new Foo();//Memory leaks here, destructor not invoked}if (1){Foo fooVar;// No memory leak as variable goes out of scope// and destructor will be invoked.}if (1){Foo* fooPtr = new Foo();delete fooPtr;// delete operator will invoke the destructor. Hence no memory leak}}

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS #include
$25