classillusfriendimp.cpp

来自「data+structures+using+c的源码」· C++ 代码 · 共 37 行

CPP
37
字号

#include <iostream>
#include "classIllusFriend.h"

using namespace std;

void classIllusFriend::print()
{
	cout<<"In class classIllusFriend: x = "<<x<<endl;
}

void classIllusFriend::setx(int a)
{
	x = a;
}

void friendFunc(classIllusFriend cIFObject)		//Line 1
{
    classIllusFriend localObject;				//Line 2

    localObject.x = 45;							//Line 3

    localObject.print();						//Line 4
    cout<<endl;									//Line 5
    cout<<"Line 6: In friendFunc accessing "
		<<"the private data member x "
		<<localObject.x<<endl;					//Line 6
	
    cIFObject.x = 88;							//Line 7

    cIFObject.print();							//Line 8
    cout<<endl;									//Line 9
    cout<<"Line 10: In friendFunc accessing "
		<<"the private data member x "
		<<cIFObject.x<<endl;					//Line 10
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?