can i declare only part of a class as another class friend?

assuimng i want only A::a to be a friend of class B (and leave A::c as is-not a friend) is there a way to do it?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>

using namespace std;

class A
{
	int a,c;
    public:
	A(int x);
};

class B
{
	int b;
    public:
	B(A a2b) {b=a2b.a;};
};
closed account (Dy7SLyTq)
well couldnt you just have a generic class ie class generic that has in its body a, then classes B which inherits from generic, and contains b, and B(A) and class A, which inherits generic and contains c and A(int)?
no, thats a qustion from an exercise and we are asked not to use inheritence
Topic archived. No new replies allowed.