I have this Word.cc that is like string class for manipulating words. I overloaded operator << as friend function, but when i keep getting this "Address of Word a() will evaluate as true". Could you comment on where I might be wrong? The code I use in main is the following.
int main()
{
Word a();
cout<<a;
return 0;
}
Word::Word()
{
init("");
}
void Word::init(char *c,char *stoppers)
{
char *temp="\0";
if(c==NULL)
c=temp;
size=strlen(c)==0 ? DEFAULT_SIZE :(strlen(c)+1+DEFAULT_SIZE)/DEFAULT_SIZE*DEFAULT_SIZE;
wd=new char[size+1];
delimiters=new char[strlen(stoppers)+1];
strcpy(wd,c);
strcpy(delimiters,stoppers);
count=strlen(wd);
}
ostream & operator<<(ostream &out,const Word &b)
{
out<<b.wd;
return out;
}