Программы на C++. Форум разработчиков
-
Гость
C++, почему компилятор не может найти перегрузку функции, когда используется пространство имен?
Сообщение
Гость »
У меня меньше четырех файлов
Код: Выделить всё
//struct.h
#pragma once
namespace coffee {
class MD2 {};
class Recorder{};
class Book{};
}
//setup.h
#pragma once
#include "struct.h"
using namespace coffee;
void wire(MD2 md2, Book book){}
//strategy.h
#pragma once
#include "struct.h"
#include "setup.h"
namespace strategy {
using namespace coffee;
int wire(MD2 md2, Recorder recorder) {}
int setup2(MD2 md2, Recorder recorder, Book book) {
wire(md2, recorder);
wire(md2, book); //
Подробнее здесь: [url]https://stackoverflow.com/questions/78174740/c-why-compiler-cant-find-function-overload-when-namespace-is-used[/url]
1710668851
Гость
У меня меньше четырех файлов
[code]//struct.h
#pragma once
namespace coffee {
class MD2 {};
class Recorder{};
class Book{};
}
//setup.h
#pragma once
#include "struct.h"
using namespace coffee;
void wire(MD2 md2, Book book){}
//strategy.h
#pragma once
#include "struct.h"
#include "setup.h"
namespace strategy {
using namespace coffee;
int wire(MD2 md2, Recorder recorder) {}
int setup2(MD2 md2, Recorder recorder, Book book) {
wire(md2, recorder);
wire(md2, book); //
Подробнее здесь: [url]https://stackoverflow.com/questions/78174740/c-why-compiler-cant-find-function-overload-when-namespace-is-used[/url]