Hi,
I have this template
Now if I do the following:Code:template <class T> class dimensions { protected: T m_xstart; T m_xend; T m_ystart; T m_yend; public: inline T getxstart(){return m_xstart;} inline T getxend(){return m_xend;} inline T getystart(){return m_ystart;} inline T getyend(){return m_yend;} inline void setxstart(T xstart){m_xstart = xstart;} inline void setxend(T xend){m_xend = xend;} inline void setystart(T ystart){m_ystart = ystart;} inline void setyend(T yend){m_yend = yend;} inline double getaspectratio() { T width = m_xend - m_xstart; T height = m_yend - m_ystart; if (height) return width / height;} };
"ratio" is allways zero. I expect it to be 0.5. Why is this?Code:dimensions<double> dim; dim.setxstart(0); dim.setxend(500); dim.setystart(0); dim.setyend(1000); double ratio = dim.getaspectratio();
Thanks in advance
Juergen




Reply With Quote