Код: Выделить всё
a.hКод: Выделить всё
#include "b.cpp" // comment these lines to make everything work
#pragma once
class A{
B *other = nullptr; // comment these lines to make everything work
void run();
};
< /code>
a.cppКод: Выделить всё
#include
#include "a.h"
#pragma once
void A::run() {
std::cout
b.cppКод: Выделить всё
#include
#include "b.h"
#pragma once
void B::go() {
std::cout
But if you comment the two lines in a.h file, you get the desired Hello world output. So as far as I understand, the compiler loads main.cpp -> a.cpp -> a.h -> b.cpp -> b.h -> a.cpp#ifndef smth
#define smth
// the code
#endif
< /code>
but it didn't work either. What should I try next?
Подробнее здесь: https://stackoverflow.com/questions/795 ... definition
Мобильная версия