I have 2 Classes Namely A and B with following independent declaration
class A {
private:
std::vector<B> vec = {B("X","Y")};
public:
A();
void clear(std::vector<B>::size_type index);
};
class B {
private:
std::string m_first;
std::string m_second;
public:
B() = default;
B(std::string first, std::string second) : m_first(first), m_second(second) {}
// I want the friend below - how to do it?
friend void A::clear(std::vector<B>::size_type index);
};
I want to declare void A::clear(std::vector<B>::size_type index) to be friend of class B. Is it possible in C++? I cannot do forward declaration of B for A as A needs to see B's constructor with 2 arguments.