Issue while I try to assign a QSharedPointer to a variable



  • Hello,
    I make some as follows.

      QSharedPointer<User> pointer(new User());
      // UserSettings is a Class
      const UserSettings &userSettingsRef = pointer; 
    

    Complie error should happen, but it not.
    Could somebody tell me why?


  • Moderators

    Hi! This gives me the following compile error:

    invalid initialization of reference of type 'const UserSettings&' from expression of type 'QSharedPointer<User>'
         const UserSettings &userSettingsRef = pointer;
                                               ^
    

    What's your platform / compiler?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.