C++教程:C++友元函数讲解

2020-01-06 12:35:47王冬梅

#include "Linklist.h"
using namespace std;
int main()
{
   int tempi;
   char tempc;
   cout <<"请输入一个整数和一个字符:" <<endl;
   cin >>tempi >>tempc;
   Linklist a(tempi,tempc);
   a.Locate(tempi);
   a.Insert(1,'C');
   a.Insert(2,'B');
   cout <<"After Insert" <<endl;
   a.Show();
   Node b(4,'F');
   cout <<"An independent node created" <<endl;
   cout <<"Use friend function to show node" <<endl;
   ShowNode(b);//用友元函数输出b结点的内容