1 Star 0 Fork 0

konica/cpp

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
class_Line.cpp 637 Bytes
一键复制 编辑 原始数据 按行查看 历史
konica 提交于 2018-02-22 10:17 +08:00 . dsf
#include <iostream>
using namespace std;
class Line
{
public:
int getLength()
{
return *ptr;
}
Line(int Len = 1)
{
cout << "init" << endl;
ptr = new int;
*ptr = Len;
}
Line(const Line &obj)
{
cout << "copy" << endl;
ptr = new int;
*ptr = *obj.ptr;
}
~Line()
{
cout << "destroy" << endl;
delete ptr;
}
private:
int *ptr;
};
void display(Line obj)
{
cout << obj.getLength() << endl;
}
int main()
{
cout << (1 < 0) << endl;
Line line;
Line line2 = line;
display(line2);
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/konica/cpp.git
git@gitee.com:konica/cpp.git
konica
cpp
cpp
master

搜索帮助