//my test 1.6
/////////////////////////////////////////////////////////////////
// 利用函数在被调用时,其参数“采用引用调”而非“传值调用” //
//的方法,可以实现有“多个输出”的效果!!!即实现IEC61131-3中结构化 //
//文本编程语言之FUNCTION_BLOCK功能。(比如我们在SIEMENS SCL语言 //
//和ABB和SUPCON ST语言中的FUNCTION_BLOCK块) //
/////////////////////////////////////////////////////////////////
#include
using std::cin;
using std::cout;
using std::endl;
using std::ios;
#include
using std::setw;
using std::setiosflags;
using std::setprecision;
#include
int main()
{
int dummy1=0,
dummy2=0,
c1=81,
c2=82,
c3=83,
c4=84,
c5=85;
cout << endl<< endl;
cout << "———c1~c5的初始值——— "<< endl;
cout << " c1 " << c1 < cout << " c2 " << c2 < cout << " c3 " << c3 < cout << " c4 " << c4 < cout << " c5 " << c5 <
int function1(int ,int &,int &,int &,int &,int &);
dummy1 = function1(dummy2,c1,c2,c3,c4,c5);
cout << "——修改后c1~c5的值等于引用调用hh1~hh5的值——— "<< endl;
cout << " c1 " << c1 < cout << " c2 " << c2 < cout << " c3 " << c3 < cout << " c4 " << c4 < cout << " c5 " << c5 < cout << endl<< endl;
return 0;
}
int function1(int kk,int &hh1,int &hh2,int &hh3,int &hh4,int &hh5)
{
int a=1;
hh1 = hh1 + 10;
hh2 = hh2 + 10;
hh3 = hh3 + 10;
hh4 = hh4 + 10;
hh5 = hh5 + 10;
cout << "——在函数中引用并修改—— "<< endl;
cout << " hh1 " << hh1 < cout << " hh2 " << hh2 < cout << " hh3 " << hh3 < cout << " hh4 " << hh4 < cout << " hh5 " << hh5 < kk = 55;
return kk;
}