Inspection incorrectly triggers "inaccessible private member" warning

已回答

Hello. The following code compiles without errors and warnings but IDE underlines a piece of code and says that "private 'Class1::k' is inaccessible". Am I missing something or is this a bug?

#include <iostream>

template<class T>
class Class1 {
int k = 1;
template<class> friend class Class2;
};

template<class T>
class Class2 {
public:
void function() {
std::cout << element.k;
}

private:
Class1<T> element;
};

int main() {
Class2<int>().function();
return 0;
}

 

0

Hi! I can reproduce the issue with 2017.3.4 and can't reproduce with 2018.1. Looks like https://youtrack.jetbrains.com/issue/CPP-10743 which was fixed in 2018.1.

1
Avatar
Permanently deleted user

Thank you. That seems to be the case. Updating IDE has solved the problem.

0

请先登录再写评论。