Conversion function error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris

    #1

    Conversion function error

    I have a template class called Image and I want to make a
    conversion function to that I can easily convert one
    template type to another. I tried making functions for a
    couple specific cases, but I get an error that says it
    will cause a stack overflow. I don't think my function
    should do that, so maybe I did something wrong. Here is
    the function in question (I have it defined in the class
    declaration in the header file).

    operator Image<float>()
    {
    Image<float> newImage(*this, false);
    Image<float>::i terator iterNew = newImage.begin( );
    for(iterator iter = begin(); !iter.end(); ++iter,
    ++iterNew) {
    *iterNew = float(*iter); }
    return newImage;
    }


    Here is the exact error:

    image.h(78) : warning
    C4717: 'ImageNS::Image <double>::opera tor
    ImageNS::Image< float>' : recursive on all control paths,
    function will cause runtime stack overflow



    I'm pretty sure this function is not recursive, it
    shoudldn't be. Is this my fault or a problem with visual
    studio .net 2003?

    Thanks,
    Chris
Working...