Define a class template named Alice that takes a single type parameter. Make Alice a friend of all instances of a template class named Friendly. Give Alice member functions that demonstrate its friendship.
#include <iostream>
using namespace std;
class Friendly;
template <class T>
class Alice
{
private:
T x;
friend class Friendly;
public:
Alice() : x(10) {}
};
class Friendly {
  private:
    int y;
  public:
  Friendly() : y(13) {}
  int add() {
    Alice<int> obj;
    return obj.x + y;
  }
};
int main(){
  return 0;
}
Comments
Leave a comment