firstfile.cpp
Код: Выделить всё
export module ModTest;
export import :Two;
export class FirstClass {
public:
FirstClass();
int firstClassFunc();
};
< /code>
firstfile_impl.cpp
module ModTest;
int FirstClass::firstClassFunc() { return 8; }
FirstClass::FirstClass()
{
SecondClass sec(this);
}
< /code>
secondfile.cpp
export module ModTest:Two;
class FirstClass;
export class SecondClass {
public:
SecondClass(FirstClass *parent){}
SecondClass(const SecondClass&) noexcept = delete;
SecondClass(const SecondClass&&) noexcept = delete;
SecondClass& operator=(const SecondClass&) noexcept = delete;
SecondClass& operator=(SecondClass&&) noexcept = delete;
};
< /code>
Это просто хорошо, но когда я пытаюсь использовать его в другом проекте: < /p>
FirstClass *firstCl = new FirstClass();
SecondClass sec(firstCl);
< /code>
Я получаю эти ошибки, которые не имеют смысла для меня: < /p>
1>C:\ecworks_mep\_WINOHNEDLL\src\mainframe.cpp(358,17): error C2665: 'SecondClass::SecondClass': no overloaded function could convert all the argument types
1>(compiling source file '../src/mainframe.cpp')
1> C:\ecworks_mep\moduleTest\moduleTest\secondFile.cpp(9,2):
1> could be 'SecondClass::SecondClass(const SecondClass &&) noexcept'
1> C:\ecworks_mep\_WINOHNEDLL\src\mainframe.cpp(358,17):
1> 'SecondClass::SecondClass(const SecondClass &&) noexcept': cannot convert argument 1 from 'FirstClass *' to 'const SecondClass &&'
1> C:\ecworks_mep\_WINOHNEDLL\src\mainframe.cpp(358,18):
1> Reason: cannot convert from 'FirstClass *' to 'const SecondClass'
1> C:\ecworks_mep\moduleTest\moduleTest\secondFile.cpp(8,2):
1> or 'SecondClass::SecondClass(const SecondClass &) noexcept'
1> C:\ecworks_mep\_WINOHNEDLL\src\mainframe.cpp(358,17):
1> 'SecondClass::SecondClass(const SecondClass &) noexcept': cannot convert argument 1 from 'FirstClass *' to 'const SecondClass &'
1> C:\ecworks_mep\_WINOHNEDLL\src\mainframe.cpp(358,18):
1> Reason: cannot convert from 'FirstClass *' to 'const SecondClass'
1> C:\ecworks_mep\moduleTest\moduleTest\secondFile.cpp(7,2):
1> or 'SecondClass::SecondClass(FirstClass *)'
1> C:\ecworks_mep\_WINOHNEDLL\src\mainframe.cpp(358,17):
1> 'SecondClass::SecondClass(FirstClass *)': cannot convert argument 1 from 'FirstClass *' to 'FirstClass *'
1> C:\ecworks_mep\_WINOHNEDLL\src\mainframe.cpp(358,18):
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
1> C:\ecworks_mep\_WINOHNEDLL\src\mainframe.cpp(358,17):
1> while trying to match the argument list '(FirstClass *)'
1>Done building project "mepOhneDll4.vcxproj" -- FAILED.
Я попытался явно удалить конструктор, упомянутый в сообщении об ошибке, но, похоже, он просто игнорируется компилятором.
Подробнее здесь: https://stackoverflow.com/questions/796 ... n-a-module
Мобильная версия