August 1st, 2014, 04:12 AM
Help in operator << >> overloading in Library
Above compile and build ok. But when i build another library that use the above, i was shown with all errors complaining operator << and >> definition of dllimport finction not allowed
class VAR_EXPORT VAR
VAR_EXPORT QDataStream &operator>>(QDataStream &p_stream, QSharedPointer<Data>& p_data)
VAR_EXPORT QDataStream & operator<<(QDataStream &p_stream, const Data & p_data)
VAR_EXPORT QDataStream &operator<<(QDataStream &p_stream, QSharedPointer<Data> p_data)
return p_stream << *p_data;
error C2491: 'operator >>' : definition of dllimport function not allowed
error C2491: 'operator <<' : definition of dllimport function not allowed
Last edited by mce; August 1st, 2014 at 04:41 AM.
August 4th, 2014, 10:37 AM
Re: Help in operator << >> overloading in Library
You are supoosed to *declare* your functions with dll import/export in your .h), and the *define* them without dll import/export (in your cpp).
Is your question related to IO?
Read this C++ FAQ LITE article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.