Help in operator << >> overloading in Library
Code:
class VAR_EXPORT VAR
{
public:
};
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;
}
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
error C2491: 'operator >>' : definition of dllimport function not allowed
error C2491: 'operator <<' : definition of dllimport function not allowed
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).