Error c2504 не определен базовый класс

I checked out a post similar to this but the linkage was different the issue was never resolved. The problem with mine is that for some reason the linker is expecting there to be a definition for the

I checked out a post similar to this but the linkage was different the issue was never resolved. The problem with mine is that for some reason the linker is expecting there to be a definition for the base class, but the base class is just a interface. Below is the error in it’s entirety

c:usersnumerical25desktopintro todirectxgodfilesgxrendermanagergxrendermanagergxrendermanagergxdx.h(2) : error C2504: 'GXRenderer' : base class undefined

Below is the code that shows how the headers link with one another

GXRenderManager.h

#ifndef GXRM
#define GXRM
#include <windows.h>
#include "GXRenderer.h"
#include "GXDX.h"
#include "GXGL.h"

enum GXDEVICE {
    DIRECTX,
    OPENGL
};

class GXRenderManager {
public:
    static int Ignite(GXDEVICE);

private:
    static GXRenderer *renderDevice;

};

#endif

at the top of GxRenderManager, there is GXRenderer , windows, GXDX, GXGL headers. I am assuming by including them all in this document. they all link to one another as if they were all in the same document. correct me if I am wrong cause that’s how a view headers. Moving on…

GXRenderer.h

class GXRenderer {

public:
    virtual void Render() = 0;
    virtual void StartUp() = 0;

};

GXGL.h

class GXGL: public GXRenderer {

public:
    void Render();
    void StartUp();
};

GXDX.h

class GXDX: public GXRenderer {
public:
    void Render();
    void StartUp();
};

GXGL.cpp and GXDX.cpp respectively

#include "GXGL.h"

void GXGL::Render()
{

}

void GXGL::StartUp()
{

}

//...Next document

#include "GXDX.h"


void GXDX::Render()
{

}

void GXDX::StartUp()
{

}

Not sure whats going on. I think its how I am linking the documents, I am not sure.

I checked out a post similar to this but the linkage was different the issue was never resolved. The problem with mine is that for some reason the linker is expecting there to be a definition for the base class, but the base class is just a interface. Below is the error in it’s entirety

c:usersnumerical25desktopintro todirectxgodfilesgxrendermanagergxrendermanagergxrendermanagergxdx.h(2) : error C2504: 'GXRenderer' : base class undefined

Below is the code that shows how the headers link with one another

GXRenderManager.h

#ifndef GXRM
#define GXRM
#include <windows.h>
#include "GXRenderer.h"
#include "GXDX.h"
#include "GXGL.h"

enum GXDEVICE {
    DIRECTX,
    OPENGL
};

class GXRenderManager {
public:
    static int Ignite(GXDEVICE);

private:
    static GXRenderer *renderDevice;

};

#endif

at the top of GxRenderManager, there is GXRenderer , windows, GXDX, GXGL headers. I am assuming by including them all in this document. they all link to one another as if they were all in the same document. correct me if I am wrong cause that’s how a view headers. Moving on…

GXRenderer.h

class GXRenderer {

public:
    virtual void Render() = 0;
    virtual void StartUp() = 0;

};

GXGL.h

class GXGL: public GXRenderer {

public:
    void Render();
    void StartUp();
};

GXDX.h

class GXDX: public GXRenderer {
public:
    void Render();
    void StartUp();
};

GXGL.cpp and GXDX.cpp respectively

#include "GXGL.h"

void GXGL::Render()
{

}

void GXGL::StartUp()
{

}

//...Next document

#include "GXDX.h"


void GXDX::Render()
{

}

void GXDX::StartUp()
{

}

Not sure whats going on. I think its how I am linking the documents, I am not sure.

Just had the same issue. @TheUndeadFish’s answer was a great help, but it took me a while to find the root cause. I’d share below a sample scenario that causes this issue and steps I performed to track it down.

So let’s assume we have three simple classes:

// a.h
#pragma once
#include "b.h"
#include "c.h"

class b;
class c;

class a {
    b* field_b;
    c* field_c;
public:
    a();
};

a depends on b and c.

// b.h
#pragma once
#include "a.h"

class a;

class b {
    a* field_a;
public:
    b();
};

b circularly depends on a (I’m solving that with forward declaration).

// c.h
#pragma once
#include "b.h"

class c : public b {
public:
    c();
};

c derives from b.

The implementation files are very simple as well (only for the sake of simplicity I’m putting all of them in a single block, but keep in mind that those are three separate files):

// a.cpp
#include "a.h"
a::a() { }
// b.cpp
#include "b.h"
b::b() { }
// c.cpp
#include "c.h"
c::c() { }

Now add them to your project, try to compile, and you’ll get something similar to the following error (I’m using Visual Studio):

1>Z:testc.h(6,20): error C2504: ‘b’: base class undefined

So we already know that the problem lies in a fact that in a particular compilation unit compiler sees the child class before it sees the parent class.
How can we prove that? The simplest approach will be to use the message pragma.
I’ve added two messages inside each of the header files, one at the top (before all the include directives) and another one right before the class definition. For example, this is how c.h now looks like:

#pragma once
#pragma message("Top in: " __FILE__)
#include "b.h"

#pragma message("Before class in: " __FILE__)
class c : public b {
public:
    c();
};

Rebuilding the project will show the following output:

Rebuild started…
1>—— Rebuild All started: Project: test, Configuration: Debug x64 ——
1>a.cpp
// redacted..
1>b.cpp
1>Top in: Z:testb.h
1>Top in: Z:testa.h
1>Top in: Z:testc.h
1>Before class in: Z:testc.h
1>Z:testc.h(6,20): error C2504: ‘b’: base class undefined
1>Before class in: Z:testa.h
1>Before class in: Z:testb.h
1>c.cpp
// redacted..
1>Generating Code…
1>Done building project «test.vcxproj» — FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Please note that b.cpp‘s compilation unit (in bold) fails, and we see where exactly and why: compiler sees the c‘s class definition before it sees b‘s class definition.
A simple fix here will be to move the #include "a.h" directive from b.h into b.cpp. Rebuild the project, and this time the compiler will see the class definitions in a desired order:

Rebuild started…
1>—— Rebuild All started: Project: test, Configuration: Debug x64 ——
1>a.cpp
// redacted
1>b.cpp
1>Top in: Z:testb.h
1>Before class in: Z:testb.h
1>Top in: Z:testa.h
1>Top in: Z:testc.h
1>Before class in: Z:testc.h
1>Before class in: Z:testa.h
1>c.cpp
// redacted
1>Generating Code…
1>test.vcxproj -> test.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

  • Remove From My Forums
  • Question

  • Hi everyone and thank you for reading this, though the problem seems simple but unable to find a way to compile successfully

    to make the problem at it’s simplest form here is the entire code for a console application (C++ native)

    #include «stdafx.h»

    template<typename T> class Base; // forward declaring

    class First : Base<First> { };

    template <typename T> class Second: First { };

    template<typename T> class Base: Second<T> { };

    int _tmain(int argc, _TCHAR* argv[])
    {
     return 0;
    }

    as I see that the forward declaration is not working!! and no matter what sequance I use these classes this error will come for one of these classes.

    what I think I am missing is settings in the compiler that I don’t know about.

    anyone please..

    Thanks in advance.

Answers

  • The forward declaration is correct, however, base class must be defined at the place where derived class defined, following code will compile:

    Code Block

    template<typename T> class Base; // forward declaring

    class First { 
    friend Base<int>; // OK
    };

    template <typename T> class Second: First { };

    template<typename T> class Base: Second<T> { };

    hope it helps

    rico

    msm.ru

    Нравится ресурс?

    Помоги проекту!

    >
    Ошибка С2504 — не определен базовый класс

    • Подписаться на тему
    • Сообщить другу
    • Скачать/распечатать тему



    Сообщ.
    #1

    ,
    16.06.17, 07:10

      Доброе время суток
      ПОМОГИТЕЕЕЕЕЕ!!!!Пожалуйста :rolleyes:

      Суть вот в чем:

      ExpandedWrap disabled

        base.h base

        pragma once

        class Cbase

        {

        //…

        };

        base.cpp base

        //реализация base

      ExpandedWrap disabled

        child.h child

        pragma once

        class Cchild: public Cbase

        {

        //…

        };

        child.cpp

        #include «base.h»

        #include «child.h»

        //Реализация Cchild

      Все работало!!!!!!
      Добавляю так же Cchild2 — И ОШИБКА!!!! :unsure: :wacko:
      Удалил из проекта файлы Cchild2!!! Все равно эта ошибка :unsure: :wall:
      Вот че это за … такая? :unsure:

      Сообщение отредактировано: agapUP — 16.06.17, 07:12


      JoeUser



      Сообщ.
      #2

      ,
      16.06.17, 08:33

        Опубликуй весь код нормально, ибо приходится только гадать.
        А если «убираешь» модули (классы) — пересобирай проект полностью, с удалением старых объектных модулей.


        KILLER



        Сообщ.
        #3

        ,
        16.06.17, 08:57

          Цитата agapUP @ 16.06.17, 08:33

          Вот че это за … такая? :unsure:

          А с чего ты вдруг решил что оно по другому должно работать? Вот ты написал:

          ExpandedWrap disabled

            child.h child

            pragma once

            class Cchild: public Cbase

            {

            //…

            };

          Расскажи пожалуйста, откуда компилятор, при компиляции этого кода будет знать что такое CBase и где он объявлен?
          Ты не пробовал #include «base.h» подключить в *.h файл?

          Добавлено 16.06.17, 08:58

          Цитата agapUP @ 16.06.17, 07:10

          Все работало!!!!!!

          Очень странно что оно все работало. Не должно было работать, должно было выдать вот такую ошибку, которую ты сейчас и получил.

          Сообщение отредактировано: KILLER — 16.06.17, 08:58


          agapUP



          Сообщ.
          #4

          ,
          16.06.17, 10:33

            Цитата KILLER @ 16.06.17, 08:57

            Ты не пробовал #include «base.h» подключить в *.h файл?

            Подключил — работает! НО! Разве я этого не писал?…

            ExpandedWrap disabled

              child.cpp

              #include «base.h»

              #include «child.h»

            Тут какая логика, этот «Cbase» — общие алгоритмы: нутация, расчет векторов и т.д…
            Его поля и методы используются, скажем, в Child1,Child2,Child3….
            Теперь обобщенная логика main():

            ExpandedWrap disabled

              #include «child1.h»

              #include «child2.h»

              #include «child3.h»

              //…

              void main()

              {

              //Задача 2

              child2.task()

              //Анализ данных

              //…

              //Задача 1

              child1.task()

              //Анализ данных

              //…

              //Задача 1

              child3.task()

              //Анализ данных

              //…

              }

            И тут возникает вопрос: а что мне скажет компилятор на многократное подключение «base.h»? :unsure:


            Kray74



            Сообщ.
            #5

            ,
            16.06.17, 10:36

              Цитата agapUP @ 16.06.17, 10:33

              И тут возникает вопрос: а что мне скажет компилятор на многократное подключение «base.h»?

              Ничего не скажет, pragma once для этого и нужен, чтобы включал только один раз

              Сообщение отредактировано: Kray74 — 16.06.17, 10:36


              KILLER



              Сообщ.
              #6

              ,
              16.06.17, 12:13

                Цитата agapUP @ 16.06.17, 10:33

                Разве я этого не писал?…

                Это ты написал в cpp файле, после отработки препроцессора, у тебя в твой cpp файл, включится *.h файл и будет все выглядеть вот так вот:

                ExpandedWrap disabled

                  // child.tmp — это выходной файл, который сгенерируется после того, как отработает препроцессор

                  class Cchild: public Cbase

                  {

                  //…

                  };

                  class Cbase

                  {

                  //…

                  };

                  //! Реализация Cchild

                И выходит, что в точке, где ты объявляешь свой класс Cchild — компилятор ничего не знает про тот класс, от которого ты наследуешься(в твоем случае про класс Cbase), он узнает о том, где он объявлен и что это за класс уже ниже. А до этого он про него не знает, вот он тебе и говорит — я не знаю что за такой класс, от которого ты наследуешься.

                Сообщение отредактировано: KILLER — 16.06.17, 12:15


                agapUP



                Сообщ.
                #7

                ,
                19.06.17, 12:24

                  Спасибо :thanks:

                  Не думал, что препроцессор так переворачивает подключения :unsure: :blink:
                  Всегда так подключал

                  ExpandedWrap disabled

                    *.cpp

                    //все включения

                    #include <>

                    e.g.:#include «base.h»

                    e.g.:#include «child.h»

                    Cchild::Cchild() {}

                    //И т.д.

                    //…

                  Не жалую я подключения хидеров в *.h-файлы!


                  Kray74



                  Сообщ.
                  #8

                  ,
                  19.06.17, 13:36

                    Цитата agapUP @ 19.06.17, 12:24

                    Не жалую я подключения хидеров в *.h-файлы!

                    Ну почему же? Если в *.h файле есть зависимость, то пусть он хэдер с этой зависимостью и подключает.


                    KILLER



                    Сообщ.
                    #9

                    ,
                    19.06.17, 13:52

                      Цитата agapUP @ 19.06.17, 12:24

                      Не думал, что препроцессор так переворачивает подключения :unsure: :blink:

                      Ничего он не переворачивает, в С/С++ единица компиляции считается с/cpp файл. #include — макрос

                      вот ты пишешь:

                      ExpandedWrap disabled

                        //! File: A.h

                        #ifndef _A_H_

                        #define _A_H_

                        class A

                        {

                        };

                        #endif

                      ExpandedWrap disabled

                        //! File: A.cpp

                        #include «A.h»

                        //! реализация

                        A::A()

                        {

                        }

                      В итоге у тебя есть 1 класс, который разнесен на два файла, как только ты запустишь компиляцию, препроцессор вместо строчки #include «A.h» подставит содержимое этого файла(к слову так даже массивы можно объявлять.)
                      А теперь расскажи следующее, ты написал:

                      ExpandedWrap disabled

                        //! File: A.h

                        #ifndef _A_H_

                        #define _A_H_

                        class A : public CBase

                        {

                        };

                        #endif

                      Что такое CBase ? Верно ты не знаешь, а с какого перепуга компилятор должен об этом узнать? Другое дело, что есть инструменты сказать компилятору о том, чтоб он особо не ругался, т.к. какой нибудь класс уже где то объявлен, например это касается forward declarations, но допустимы если у тебя ссылочный тип данных или указатель. А тут наследование, соответственно, чтобы компилятор знал что это за тип, ему его нужно объявить, а у тебя идет использование типа до того, как ты его объявил.

                      Сообщение отредактировано: KILLER — 19.06.17, 13:53


                      JoeUser



                      Сообщ.
                      #10

                      ,
                      19.06.17, 15:42

                        Цитата KILLER @ 19.06.17, 13:52

                        #include — макрос

                        Если точнее — директива препроцессора.


                        agapUP



                        Сообщ.
                        #11

                        ,
                        20.06.17, 10:42

                          Доброе время суток
                          Спасибо, что уделяете мне время :thanks:
                          KILLER, спасибо за разъяснения :thanks:

                          НО!! Чем мой пример отличается от концепции С++?! :unsure: :blink:
                          Прошу у Вас прощения :blush: , видать я не очень наглядно продемонстрировал вопрос…
                          Попытаюсь исправить:

                          ExpandedWrap disabled

                            //ipo1.h

                            clas Cipo: public CCommAlg

                            {

                            //…

                            };

                            //…

                            //Конец ipo1.h

                            //ipo1.cpp

                            #include <vector>

                            //…

                            #include <string>

                            #include <hrono>

                            //…

                            #include «CommAlg.h» !!!!!!!!!!!!!!!!!!!!!!!!!!

                            //…

                            #include «ipo1.h» !!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                            /*

                            РЕАЛИЗАЦИЯ МЕТОДОВ Cipo1

                            */

                            //Конец ipo1.cpp

                          Так вот чем может (по концепции) реализация в ipo1.cpp:

                          ExpandedWrap disabled

                            //…

                            #include «CommAlg.h»

                            //…

                            #include «ipo1.h»

                            //…

                          Может отличаться от:

                          ExpandedWrap disabled

                            #pragma once

                            #include «CommAlg.h»

                            class Cipo: public CCommAlg

                          ? :unsure:
                          Ведь поля класса типа string определяются в описании самого класса, хотя включение этой библиотеки
                          осуществляется в ipo1.cpp!!!

                          Использую компилятор VS2012

                          Цитата Kray74 @ 19.06.17, 13:36

                          Ну почему же? Если в *.h файле есть зависимость, то пусть он хэдер с этой зависимостью и подключает.

                          Знаете… Для меня это как-то не убедительно звучит! Вот пример, стандартные библиотеки, типа #include <string> — у меня и в мыслях нет их в хедер загонять!!!!! Даже и не экспериментировал! Когда использовал «ifndef …» — компелятор ругался о многократном включении. Вот и сформировалось у меня такое представление. А зависимость показана в реализации: файл ipo1.cpp

                          Сообщение отредактировано: agapUP — 20.06.17, 10:46


                          _lcf_



                          Сообщ.
                          #12

                          ,
                          20.06.17, 10:56

                            Цитата agapUP @ 20.06.17, 10:42

                            Вот пример, стандартные библиотеки, типа #include <string> — у меня и в мыслях нет их в хедер загонять!!!!

                            а это потому что ты не наследуешься от них. зафорвардить можно только классы, да и то только если будешь использовать указатели — так как они занимают фиксированный объём. ну еще енумы всякие. а если ты хочешь в хидере обьявить сам объект или наследоваться, то тогда надо делать инклюд, иначе компиль не знает сколько места надо выделить под эти объекты.

                            Сообщение отредактировано: _lcf_ — 20.06.17, 10:57


                            KILLER



                            Сообщ.
                            #13

                            ,
                            20.06.17, 10:59

                              Цитата agapUP @ 20.06.17, 10:42

                              НО!! Чем мой пример отличается от концепции С++?! :unsure: :blink:

                              В каком смысле? По концепции С++, ты написал неработающий код. Смотри? давай на пальцах, вот что ты написал:

                              ExpandedWrap disabled

                                int main()

                                {

                                   int x = 10;

                                   int result = x + y;

                                   int y = 20;

                                   std::cout << «x+y=» << result;

                                   return 0;

                                }

                              Компилятор тебе говорит — «Я не знаю что за такая переменная y в выражении int result = x + y;»
                              Что тут не понятного?

                              Цитата agapUP @ 20.06.17, 10:42

                              Ведь поля класса типа string определяются в описании самого класса, хотя включение этой библиотеки
                              осуществляется в ipo1.cpp!!!

                              Чего? Если ты не подключишь string в хидер, но будешь его там использовать — будет ровно такая же ошибка.

                              Цитата agapUP @ 20.06.17, 10:42

                              Когда использовал «ifndef …» — компелятор ругался о многократном включении. Вот и сформировалось у меня такое представление. А зависимость показана в реализации: файл ipo1.cpp

                              компилятор может ругатся о многократном включении, если отсуствуют гарды компиляции:

                              ExpandedWrap disabled

                                #ifndef __SOME_HEADER_FILE__ //! гард предотвращающий повторное включение хидера.

                                #define __SOME_HEADER_FILE__

                                //! Какие то объявления

                                #endif


                              Cfon



                              Сообщ.
                              #14

                              ,
                              20.06.17, 12:16

                                agapUP
                                все указанные инклюды препроцесовр включает в файлы cpp, причем в каждый cpp, но повторов нет из-за #pragma once


                                agapUP



                                Сообщ.
                                #15

                                ,
                                23.06.17, 07:42

                                  Доброе время суток

                                  Цитата _lcf_ @ 20.06.17, 10:56

                                  …иначе компиль не знает сколько места надо выделить под эти объекты.

                                  Я не берусь судить, ибо не знаю! :huh: :D, но после этих строк мне чет зачесалось в пятой точке ;), что мои траблы связаны с выделением-затиранием память процесса :unsure:

                                  ВОТ! Один проект! Два дочерних и один базовый:

                                  А скрины вставить не вышло…..

                                  Но там суть такая: для класса А я хидер базового включил в срр-файл класса А — и ошибки «С2504 — не определен базовый класс» не возникло!
                                  А для класса B — эта ошибка возникла! :unsure:

                                  Добавлено 23.06.17, 07:49
                                  Всем спасибо :thanks:

                                  Сообщение отредактировано: agapUP — 23.06.17, 07:49

                                  0 пользователей читают эту тему (0 гостей и 0 скрытых пользователей)

                                  0 пользователей:

                                  • Предыдущая тема
                                  • C/C++: Общие вопросы
                                  • Следующая тема

                                  Рейтинг@Mail.ru

                                  [ Script execution time: 0,0576 ]   [ 16 queries used ]   [ Generated: 9.02.23, 12:12 GMT ]  

                                  После этого урока (https://www.youtube.com/watch?v=gq2Igdc-OSI&Индекс = 52&список = PLAE85DE8440AA6B83) Я столкнулся с 4 ошибками в Visual Studio C ++ 2017. 3 из них — это одно и то же, и просто повторяется «Мать»: базовый класс не определен в файле daughter.h. Другая ошибка гласит: «sayName» не является членом «Daughter». Теперь вот код. Это довольно просто, что я хочу, чтобы программа печатала … Я хочу, чтобы она напечатала две строки «Что ты там делаешь?» Если бы вы могли помочь мне с этим ответом, это было бы здорово. Спасибо.
                                  Для основного файла
                                  `#include» stdafx.h «#include
                                  #include «Daughter.h» #include «Mother.h» с использованием пространства имен std;

                                  int main()
                                  {
                                  Mother pot;
                                  pot.sayName();
                                  Daughter kettle;
                                  kettle.sayName();
                                  int pause = 0;
                                  cin >> pause;
                                  }
                                  
                                  Mother.h
                                  #ifndef MOTHER_H
                                  #define MOTHER_H
                                  
                                  class Mother
                                  {
                                  public:
                                  Mother();
                                  void sayName();
                                  
                                  };
                                  
                                  #endif
                                  Mother.cpp
                                  #include "stdafx.h"#include<iostream>
                                  #include"Daughter.h"#include"Mother.h"using namespace std;
                                  
                                  Mother::Mother()
                                  {
                                  }
                                  void Mother::sayName() {
                                  cout << "What are you doing there?" << endl;
                                  
                                  }
                                  Daughter.h
                                  #ifndef DAUGHTER_H
                                  #define DAUGHTER_H
                                  
                                  class Daughter:public Mother
                                  {
                                  public:
                                  Daughter();
                                  };
                                  #endif
                                  Daughter.cpp
                                  #include "stdafx.h"#include<iostream>
                                  #include"Daughter.h"#include"Mother.h"using namespace std;
                                  
                                  Daughter::Daughter()
                                  {
                                  }
                                  

                                  2

                                  Решение

                                  Когда класс наследует другой, он должен включать заголовок родительского класса в свой заголовок. В вашем случае вы должны добавить #include "Mother.h" в верхней части дочернего заголовка (не только в файле .cpp). Другая ошибка происходит из-за первой, и исправление должно решить ее.

                                  Когда вы пишете синтаксис наследования class Daughter : public Motherопределение класса Daughter должно иметь доступ к информации о родительском классе по нескольким причинам. Одним из них является информация о унаследованных методах, которая стала причиной вашей второй ошибки.

                                  1

                                  Другие решения

                                  Других решений пока нет …

                                  Я проверил сообщение, подобное этому, но связь была другой, проблема не была решена. Проблема с моей заключается в том, что по какой-то причине компоновщик ожидает, что там будет определение для базового класса, но базовый класс — это просто интерфейс. Ниже приведена ошибка в целом

                                  c:usersnumerical25desktopintro todirectxgodfilesgxrendermanagergxrendermanagergxrendermanagergxdx.h(2) : error C2504: 'GXRenderer' : base class undefined
                                  

                                  Ниже приведен код, который показывает, как заголовки соединяются друг с другом

                                  GXRenderManager.h

                                  #ifndef GXRM
                                  #define GXRM
                                  #include <windows.h>
                                  #include "GXRenderer.h"
                                  #include "GXDX.h"
                                  #include "GXGL.h"
                                  
                                  enum GXDEVICE {
                                      DIRECTX,
                                      OPENGL
                                  };
                                  
                                  class GXRenderManager {
                                  public:
                                      static int Ignite(GXDEVICE);
                                  
                                  private:
                                      static GXRenderer *renderDevice;
                                  
                                  };
                                  
                                  #endif
                                  

                                  в верхней части GxRenderManager, есть заголовки GXRenderer, windows, GXDX, GXGL. Я предполагаю, включив их всех в этот документ. все они связаны друг с другом, как будто все они находятся в одном документе. исправьте меня, если я ошибаюсь, так как заголовок заголовка. Двигаемся дальше…

                                  GXRenderer.h

                                  class GXRenderer {
                                  
                                  public:
                                      virtual void Render() = 0;
                                      virtual void StartUp() = 0;
                                  
                                  };
                                  

                                  GXGL.h

                                  class GXGL: public GXRenderer {
                                  
                                  public:
                                      void Render();
                                      void StartUp();
                                  };
                                  

                                  GXDX.h

                                  class GXDX: public GXRenderer {
                                  public:
                                      void Render();
                                      void StartUp();
                                  };
                                  

                                  GXGL.cpp и GXDX.cpp соответственно

                                  #include "GXGL.h"
                                  
                                  void GXGL::Render()
                                  {
                                  
                                  }
                                  
                                  void GXGL::StartUp()
                                  {
                                  
                                  }
                                  
                                  //...Next document
                                  
                                  #include "GXDX.h"
                                  
                                  
                                  void GXDX::Render()
                                  {
                                  
                                  }
                                  
                                  void GXDX::StartUp()
                                  {
                                  
                                  }
                                  

                                  Не уверен, что происходит. Я думаю, что как я связываю документы, я не уверен.

                                  Понравилась статья? Поделить с друзьями:
                                • Error c2471 cannot update program database
                                • Error c2466 невозможно выделить память для массива постоянного нулевого размера
                                • Error c2447 отсутствует заголовок функции возможно используется формальный список старого типа
                                • Error c2447 missing function header old style formal list
                                • Error c2443 конфликт размеров операндов