passingbigstructures1.cpp
来自「ThinkingC++中文版」· C++ 代码 · 共 40 行
CPP
40 行
//: C11:PassingBigStructures.cpp
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 2000
// Copyright notice in Copyright.txt
#include <iostream>
#include <string>
using namespace std;
class Big{
public:
char buf[100];
int i;
double d;
Big(){}//缺省构造函数
Big(Big& b){}//拷贝构造函数
};
Big bigfun(Big temp) {
temp.i = 3; // Do something to the argument
temp.d = 3.3;
::strcpy(temp.buf,"I am temp!");
return temp;
}
void main()
{
Big b1, b2;
b1.i = 1;
b1.d = 1.1;
::strcpy(b1.buf,"I am b1!");
b2.i = 2;
b2.d = 2.2;
::strcpy(b2.buf,"I am b2!");
b2 = bigfun(b1);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?