Midterm2- question-1 source code

21 views
Skip to first unread message

Hacer Keles

unread,
May 3, 2013, 12:17:40 PM5/3/13
to com...@googlegroups.com
Arkadaşlar, cevabı öğrenmek için aşağıdaki kodu çalıştırın lütfen..


--------------------------------------------
#include <iostream>
using namespace std;

class A
{
public: 
static int counter;
A()
{
counter++;
}
~A()
{
counter--;
}
};
int A::counter=0;

void f()
{
A arr[2];
{
A* p1 = new A[2];
{
A* p2 = new A[3];
A arr[2];
}
delete [] p1;
}

}

int main()
{
f();
cout<<A::counter<<endl;
}

Reply all
Reply to author
Forward
0 new messages