Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Inherit problem in the class
Qt 6.11 is out! See what's new in the release blog

Inherit problem in the class

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 343 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
    mena_mes
    wrote on last edited by mena_mes
    #1

    Hi everyone,

    I am new in Qt world :)

    I created 2 class one inherit from the other one. Please find below my code :

    #include "cclass2.h"
    
    
    class CClass1
    {
    public:
        explicit CClass1(CClass2& p_class);
        ~CClass1();
    public: // Data
     
    protected:
        CClass2& p_class2;
    
    };
    

    but I get the error : expected ')' before '&' token explicit CClass1(CClass2& snapshot);

    any help please

    Pl45m4P jsulmJ 2 Replies Last reply
    0
    • M mena_mes

      Hi everyone,

      I am new in Qt world :)

      I created 2 class one inherit from the other one. Please find below my code :

      #include "cclass2.h"
      
      
      class CClass1
      {
      public:
          explicit CClass1(CClass2& p_class);
          ~CClass1();
      public: // Data
       
      protected:
          CClass2& p_class2;
      
      };
      

      but I get the error : expected ')' before '&' token explicit CClass1(CClass2& snapshot);

      any help please

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @mena_mes

      This has nothing to do with Qt. It's just plain C++

      Where exactly do you get this error? In your class header or when create an instance of it?


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      1
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        @mena_mes said in Inherit problem in the class:

        but I get the error : expected ')' before '&' token explicit CClass1(CClass1& snapshot);

        The code snippet mentioned in the error message does not exist in the code you posted. Start by looking for the code that matches the error message; possibly in the C++ source providing the implemenation.

        1 Reply Last reply
        1
        • M mena_mes

          Hi everyone,

          I am new in Qt world :)

          I created 2 class one inherit from the other one. Please find below my code :

          #include "cclass2.h"
          
          
          class CClass1
          {
          public:
              explicit CClass1(CClass2& p_class);
              ~CClass1();
          public: // Data
           
          protected:
              CClass2& p_class2;
          
          };
          

          but I get the error : expected ')' before '&' token explicit CClass1(CClass2& snapshot);

          any help please

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #4

          @mena_mes In the code you posted I don't see any inheritance.
          Does CClass2 inherit from CClass1?
          Does cclass2.h include cclass1.h? If so you have circular dependency. Change

          CClass2& p_class2;
          

          to

          CClass2 *p_class2;
          

          Remove

          #include "cclass2.h"
          

          and add

          class CClass2; // Forward declaration
          

          before CClass1 declaration.
          And as already pointed out: this has nothing to do with Qt.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          4

          • Login

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