【发布时间】:2020-12-29 17:26:35
【问题描述】:
考虑a.hpp
class foo{
int c;
};
和b.hpp
class bar;
class foo{
friend bar;
// from here identical to a.hpp
int c;
};
严格来说,是否违反了 ODR?
【问题讨论】:
-
“同班同学不同”他们没有任何区别,他们是相同的
-
是的,但是第二类有一种通过
bar访问私有数据的方法,第一类没有。 -
为什么不在第一个?
-
@largest_prime_is_463035818:复制粘贴出错,第一个声明没有朋友,已编辑。