📄 pr06029.cpp
字号:
////////////////////////////////////////
// File Name: pr06029.cpp
////////////////////////////////////////
#include <iostream>
// A big structure.
struct bigone
{
int serno;
char text[1000];
};
// Two function prototypes with a structure parameter.
void slowfunc(bigone p1); // Call by value.
void fastfunc(bigone& p1); // Call by reference.
////////////////////////////////////////
// The main() function.
////////////////////////////////////////
int main()
{
static bigone bo = {123, "This is a BIG structure"};
// This call will take a while.
slowfunc(bo);
// This call will be faster than the previous one.
fastfunc(bo);
return 0;
}
////////////////////////////////////////
// A call-by-value function.
////////////////////////////////////////
void slowfunc(bigone p1)
{
std::cout << p1.serno << std::endl;
std::cout << p1.text << std::endl;
}
////////////////////////////////////////
// A call by reference function.
////////////////////////////////////////
void fastfunc(bigone& p1)
{
std::cout << p1.serno << std::endl;
std::cout << p1.text << std::endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -