CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2002

    Help in operator << >> overloading in Library

    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;
    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
    Last edited by mce; August 1st, 2014 at 03:41 AM.

  2. #2
    Join Date
    Jun 2009

    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 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.