Without Using Friend Class
#include <stdafx.h> 
#include <iostream>
#include <string>
using namespace std; 
class TestFriend
{
  // Without using friend class.
  int i;  // Here i is a private member of the class TestFriend.
  
};
class MyClass 
{
  public:
    void display(int a)
    {
      TestFriend tf;
      tf.i=a;    // Trying to access the private member i of the class TestFriend.
      cout<< "Value of the private member :" << tf.i;
    }
};
int main() 
{  
  MyClass mc;
  mc.display(100);
  
  return 0;  
}
Output:
Error  1  error C2248: 'TestFriend::i' : cannot access private member declared in class 'TestFriend'  d:myworkmyworkmywork.cpp  20  1  MyWork
error C2248: 'TestFriend::i' : cannot access private member declared in class 'TestFriend'