0

I have to make a Chain of Mountains that contains other chains or simple mountains. For that reason I constructed a Class Mountain and then two sub-class. The subclass Chain and the subclass MountainSingle. The class chain contains itself a vector of pointers to other objects of type Mountain(Thus I have a vector containing pointers to other MountainSingle or Chain). My code is the following:

CLASS CHAIN

          Chain* Chain::copie() const {
            return (new Chain(*this));
            }

          Chain::Chain(Chain const & other){
              for(auto element: other.ChainofChain){
                  ChainofChain.push_back(element->copie());
              }
          }

          void Chain::dessine_sur(SupportADessin  & support) const {
               for(auto element: ChainofChain){
                 element->dessine_sur(support);// erwtisi avrio na teleiwnoume
            }
          }

          std::vector<Mountain *> Chain::get_Chains() const
          {
            return ChainofChain;
          }

           double Chain::altitude(double x, double y) const {
            double alt = 0;

            for(auto element : ChainofChain)
            {
              if(element->altitude(x,y) > alt){ alt = element->altitude(x,y); }
            }
            return alt;
          }

CLASS MOUNTAIN

       #include<iostream>
       #include "Dessinable.h"
       #include "SupportADessin.h"

       class Mountain:public Dessinable{
         public:
            virtual void dessine_sur(SupportADessin & support) const override= 0;
            virtual Mountain* copie() const = 0;
            virtual double altitude(double x, double y)const =0;
            virtual ~Mountain(){}
        };

But upon compilation I get the following error. I know that there are many other posts about the issue but even if I made the small adjustements proposed I still get the following error

        Chain::Chain(Chain const & ): undefined reference to vtable for chain. 

I would love to give back a small example but, it is part of a greater programm and I cant entail everything. But what I would like to have is to be able to print a chain, which contains both MountainSingle and other Chains

Thank you in advance

Geordie D
  • 21
  • 5
  • 1
    Please [edit] your question to include a [mcve]. The problem is likely that you have a non-abstract `virtual` function in the `Chain` class that you haven't defined (implemented). – Some programmer dude May 08 '21 at 12:24
  • The problem is that it is a part of a greater program and i added another element, thus getting this error but thanks @Someprogrammerdude – Geordie D May 08 '21 at 12:29

0 Answers0