PDA

View Full Version : Code design QVariant or template<class T>



jd
15th April 2008, 14:53
Hello, i've a problem with my code design. I've read this manual about QVariant: http://doc.trolltech.com/4.3/qvariant.html

Waht is the diffrent between code1 and code2?

code1:


QString CMainWindow::myFunction( QVariant num ) {
QString tmp;
// do something

return tmp;
}


code2:


template <class T> QString CMainWindow::myFunction( T num ) {
QString tmp;
// do something

return tmp;
}


Is code1 the same as code2 only in Qt-Style?

so long

jd

wysota
15th April 2008, 23:15
code1 is a single method handling all registered types. code2 is a series of methods for different datatypes.