Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > a snippet of c++ code, i can't find the error?

Reply
Thread Tools

a snippet of c++ code, i can't find the error?

 
 
entrepreneur
Guest
Posts: n/a
 
      10-24-2006

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.

 
Reply With Quote
 
 
 
 
heltena
Guest
Posts: n/a
 
      10-24-2006
try this:

#include<iostream> // changed!
// changed!

int count=0;
class obj{
public :
obj();
~obj();
};

obj:bj() { // 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" <(E-Mail Removed)> wrote:
> 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.


 
Reply With Quote
 
 
 
 
VJ
Guest
Posts: n/a
 
      10-24-2006
entrepreneur wrote:
> this is the code:
> #include<iostream.h>
> #include<string.h>
> int count=0;
> class obj{
> public :
> obj();
> ~obj();
> };

OBJ:bj() {
> ++count;
> cout<<count<<endl;
> }

OBJ::~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.
>

 
Reply With Quote
 
Martin Steen
Guest
Posts: n/a
 
      10-24-2006
entrepreneur wrote:

> where is the error? can someone point it out for me?
> your help will be greatly appreciated.
> best regards.


Is this a joke or a test? What makes you think that
there is an error?

-Martin

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to exclude action of Find::Find::find in subdirectories withknown names? vdvorkin Perl Misc 3 02-14-2011 05:28 AM
How to exclude action of Find::Find::find in subdirectories withknown names? vdvorkin Perl Misc 0 02-10-2011 05:18 PM
Memory Leaks - Can you help me find them in ths snippet nmehring@gmail.com C++ 19 01-30-2008 10:38 AM
find item in wx.TreeListCtrl by pydata code snippet Johannes Lochmann Python 0 08-18-2006 09:38 AM
Find.find does not find orphaned links? Wybo Dekker Ruby 1 11-15-2005 02:50 PM



Advertisments