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. regarding inheritance.
Qt 6.11 is out! See what's new in the release blog

regarding inheritance.

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 6 Posters 1.7k Views 3 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.
  • Prince_0912P Offline
    Prince_0912P Offline
    Prince_0912
    wrote on last edited by
    #1

    Hello everyone, I can not inherit one class of cpp file into another class of cpp file. i get error like undefined base class etc.

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      Do you have separate *.h and *.cpp file ? Did you include the base class header file ? Are you including A class in B and B class in A ? Just check

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      1 Reply Last reply
      5
      • Prince_0912P Offline
        Prince_0912P Offline
        Prince_0912
        wrote on last edited by
        #3

        Yes i have separate .cpp and .h file and also include header file of one cpp file into another header file of cpp file. Still i get error "Base class undefined".

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

          Hi,

          The please show your code. It's impossible to tell what is going wrong without any code.

          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
          • Prince_0912P Offline
            Prince_0912P Offline
            Prince_0912
            wrote on last edited by
            #5

            Code is.. Base class is Point3d and child class is Vector3d.

            #ifndef VECTOR3D_H
            #define VECTOR3D_H

            #include <QVector3D>
            #include <QColor>
            #include <QListWidget>
            #include <QList>
            #include "point3d.h"

            class Vector3d:public Point3d
            {
            public:
            Vector3d();
            Vector3d(float xp, float yp, float zp);
            void Dispose();
            Vector3d clone();
            ....

            Error is:C2504: 'Point3d' : base class undefined

            1 Reply Last reply
            0
            • N Offline
              N Offline
              NgtLvr
              wrote on last edited by
              #6

              I'm facing the same error like :
              error: C2504: 'Point3d' : base class undefined

              mrjjM 1 Reply Last reply
              0
              • N NgtLvr

                I'm facing the same error like :
                error: C2504: 'Point3d' : base class undefined

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @NgtLvr
                hi
                and if you look in
                point3d.h

                what is the class name there ?

                N 1 Reply Last reply
                0
                • mrjjM mrjj

                  @NgtLvr
                  hi
                  and if you look in
                  point3d.h

                  what is the class name there ?

                  N Offline
                  N Offline
                  NgtLvr
                  wrote on last edited by
                  #8

                  @mrjj
                  #include "vector3d.h"
                  class Point3d
                  {

                  };

                  jsulmJ 1 Reply Last reply
                  0
                  • N NgtLvr

                    @mrjj
                    #include "vector3d.h"
                    class Point3d
                    {

                    };

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

                    @NgtLvr You have cyclic dependencies between your header files: vector3d.h includes point3d.h and point3d.h includes vector3d.h. First question is: why does your Point3d need to know anything about Vector3d?

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

                    1 Reply Last reply
                    2
                    • N Offline
                      N Offline
                      NgtLvr
                      wrote on last edited by
                      #10

                      oops!!! Sorry, You are right, there is a cyclic dependencies between two classes...

                      Thanks for your quick response...

                      1 Reply Last reply
                      1
                      • dheerendraD Offline
                        dheerendraD Offline
                        dheerendra
                        Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
                        wrote on last edited by dheerendra
                        #11

                        Cool. A->B and B->A Cyclic case. This is what I said my first response. Enjoy. Move the issue to "Solved" state.

                        Dheerendra
                        @Community Service
                        Certified Qt Specialist
                        https://www.pthinks.com

                        1 Reply Last reply
                        2
                        • Prince_0912P Offline
                          Prince_0912P Offline
                          Prince_0912
                          wrote on last edited by
                          #12

                          Yeah that's the problem as you say cause of there are huge numbers of cpp file in hierarchy so that's the matter.

                          thank you,
                          @jsulm
                          @dheerendra

                          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