简体   繁体   中英

C++: using-statement of forward-declared class generates error C2371

//A.h
class A;

//A.cpp
#include A.h
class MyA {};
using A = MyA; // error C2371  'A' : redefinition; different basic types

https://ideone.com/Aifxy2

A lot of legacy code uses the class name A .

I want new code to use the name MyA , without breaking existing code.

However, when I try to do so, I get the error C2371: 'A': redefinition; different basic types

//A.h
class MyA;
using A = MyA;

//A.cpp
#include A.h
class MyA {};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM