Nightmare1
@Nightmare1
Программист

Класс не определяется в дочернем файле после включения, почему?

Есть два файла,

LicenseKey.h
#include "LicensesProduct.h"

namespace Machinarium {
	namespace Licenses_System {

		#warning "LICENSE_KEY Class creation"
		class LicenseKey : IValidationInterface {

...


LicensesProduct.h
#include "LicenseKey.hpp"
#include "IValidationInterface.h"

namespace Machinarium {
	namespace Licenses_System {

		class LicensesProduct : public IValidationInterface, Machinarium::BaseClasses::Nameable {

		private:
			Cryptographic::CryptographicKeyPair cryptographicKeyPair;
			LicenseKey activeLicense;
...


==== Building licenses (release) ====
LicenseKey.cpp
In file included from src/LicenseKey.cpp:1:
src/LicenseKey.hpp:11:4: warning: #warning "LICENSE_KEY Class creation" [-Wcpp]
   11 |   #warning "LICENSE_KEY Class creation"
      |    ^~~~~~~
In file included from src/LicenseKey.hpp:6,
                 from src/LicenseKey.cpp:1:
src/LicensesProduct.h:17:4: error: ‘LicenseKey’ does not name a type
   17 |    LicenseKey activeLicense;


По какой причине так? По сути класс LicenseKey определяется при включении в файле LicenseKey.h
  • Вопрос задан
  • 58 просмотров
Решения вопроса 1
zagayevskiy
@zagayevskiy
Android developer at Yandex
Во-первых, у тебя почему-то где-то расширение h, а где-то hpp. Нужно привести к одному виду.
Во-вторых у тебя циклический include, это не будет работать. Это надо решать. Например, можно решить с помощью forward declaration и pimpl.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы