owh yes...i notice it now..
thx :)

--- On Sat, 10/18/08, Thomas Hruska <[EMAIL PROTECTED]> wrote:

> From: Thomas Hruska <[EMAIL PROTECTED]>
> Subject: Re: [c-prog] operator int()
> To: [email protected]
> Date: Saturday, October 18, 2008, 10:07 AM
> Jos Timanta Tarigan wrote:
> > Hi, 
> > 
> > I got a question. I have a class B that has this
> method:
> > 
> > operator int()
> > {
> >    std::cout << "int()" <<
> std::endl;
> >    return i;
> > }
> > 
> > I dont know exactly how it works but every time I call
> this method:
> > 
> > int foo1(B b)
> > {
> >    return b;
> > }
> > 
> > it prints int().
> > 
> > Any1 know?
> 
> Implicit class conversion to another type using operator
> overloading. 
> The C++ compiler makes a best-guess effort at creating a
> successful 
> compile by looking at the existing class methods and the
> type the code 
> is expecting and then creating the necessary code as
> output.  This is, 
> IMO, one of the coolest features of C++ (you can even
> "typecast" between 
> classes!) but, occasionally, one of the more annoying ones
> should you 
> depend on the feature too much.  That is, you can
> "see" a clear path to 
> the implicit solution but the compiler insists there
> isn't one.
> 
> -- 
> Thomas Hruska
> CubicleSoft President
> Ph: 517-803-4197
> 
> *NEW* MyTaskFocus 1.1
> Get on task.  Stay on task.
> 
> http://www.CubicleSoft.com/MyTaskFocus/

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to