Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Code compiles fine yet is marked as erroneous
Forum Updated to NodeBB v4.3 + New Features

Code compiles fine yet is marked as erroneous

Scheduled Pinned Locked Moved Qt Creator and other tools
qtcreator
3 Posts 2 Posters 788 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Modanung
    wrote on last edited by Modanung
    #1

    The bottom line in the following code from the Urho3D Game Engine is marked as erroneous:

    template <class T> class ObjectFactoryImpl : public ObjectFactory
    {
    public:
        /// Construct.
        ObjectFactoryImpl(Context* context) :
            ObjectFactory(context)
        {
            type_ = T::GetTypeStatic();
            baseType_ = T::GetBaseTypeStatic();
            typeName_ = T::GetTypeNameStatic();
        }  
        /// Create an object of the specific type.
        virtual SharedPtr<Object>(CreateObject()) { return SharedPtr<Object>(new T(context_)); } 
    };
    

    expected '}' got 'return'
    It compiles just fine though, should this be reported as a bug in QtCreator or magic?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      I might be wrong, but the signature of CreateObject is unusual for a function declaration. It should rather be

      virtual SharedPtr<Object> CreateObject() { return SharedPtr<Object>(new T(context_)); }

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Modanung
        wrote on last edited by
        #3

        That looks more familiar. Thanks for the clarification.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved