try this:
#include<iostream // changed!
// changed!
int count=0;
class obj{
public :
obj();
~obj();
};
obj::obj() { // changed!
++count;
std::cout<<count<<std::endl; // changed!
}
obj::~obj(){ // changed!
--count; std::cout<<count<<std::endl; // changed!
}
int main(){
obj A;
std::cout<<"begin block "<<std::endl; // changed!
obj B;
std::cout<<"end block"<<std::endl; // changed!
return 0;
}
On Oct 24, 2:37 pm, "entrepreneur" <mailtumen...@gmail.comwrote:
this is the code:
#include<iostream.h>
#include<string.h>
int count=0;
class obj{
public :
obj();
~obj();};obj() {
++count;
cout<<count<<endl;}~obj(){
--count; cout<<count<<endl;}int main(){
obj A;
cout<<"begin block "<<endl;
obj B;
cout<<"end block"<<endl;
return 0;}where is the error? can someone point it out for me?
your help will be greatly appreciated.
best regards.