博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
this point
阅读量:4550 次
发布时间:2019-06-08

本文共 482 字,大约阅读时间需要 1 分钟。

// this.cpp : 定义控制台应用程序的入口点。

//

#include "stdafx.h"

#include<iostream>

using namespace std;

class A

{

public:

A() { i = 0; }

void add() { i++;}

A*sp() { return this; }

int Is(A*s) { return s->i; }

private:

int i;

};

A*p[2];

int main()

{

A a1, *a2 = new A;

p[0] = a1.sp();

p[1] = a2;

p[0]->add();

a2->add();

p[1]->add();

cout << "i--a1:" << p[1]->Is(p[0])<<endl<< "i--a2:" << p[0]->Is(p[1]) << endl;

system("pause");

return 0;

}

转载于:https://www.cnblogs.com/summercloud/p/5537546.html

你可能感兴趣的文章
stages
查看>>
uva 101 POJ 1208 The Blocks Problem 木块问题 vector模拟
查看>>
Python 面向对象 特殊方法(魔法方法)
查看>>
[转]OData/WebApi
查看>>
[转]高颜值、好用、易扩展的微信小程序 UI 库,Powered by 有赞
查看>>
[转]SQL Server如何启用xp_cmdshell组件
查看>>
[转]微擎应用笔记3--manifest.xml文件使用说明
查看>>
Codeforces 1000C Covered Points Count 【前缀和优化】
查看>>
python高效读取文件、文件改写
查看>>
gulp
查看>>
pgsql查询优化之模糊查询
查看>>
[转]-Gradle使用手册(三):构建任务
查看>>
ExtJS下拉树
查看>>
android 调用系统相机录像并保存
查看>>
BW系统表的命名规则
查看>>
Asp.Net在IE10下出现_doPostBack未定义的解决办法 LinkButton
查看>>
《CLR via C#》Part2之Chapter5 基元类型、引用类型和值类型(一)
查看>>
1-9 RHEL7-文件权限管理
查看>>
apache服务器安装
查看>>
Search a 2D Matrix
查看>>