// 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;

}

随机推荐

  1. 网络流CodeForces. Original 589F:Gourmet and Banquet

    A gourmet came into the banquet hall, where the cooks suggested n dishes for guests. The gourmet kno ...

  2. Selenium 处理模态对话框

    模态对话框的原理 模态窗口 点击下一步的动作为,聚焦到“下一步”,然后直接回车 driver.FindElement(By.CssSelector("div.rg_btn a")) ...

  3. oracle 创建表空间、创建用户管理该表空间

    /*分为四步 *//*第1步:创建临时表空间  */create temporary tablespace user_temp  tempfile 'D:\oracle\oradata\Oracle9 ...

  4. Java IO复习(一)

    package com.zyw.file; import java.io.*; /** * Created by zyw on 2016/3/10. */ public class IOTest { ...

  5. poj 1659 Frogs' Neighborhood (贪心 + 判断度数序列是否可图)

    Frogs' Neighborhood Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 6076   Accepted: 26 ...

  6. 400. Nth Digit

    这个EASY难度的题怎么感觉比H的还难,昨天没做出来,今天才做出来.. 呃啊..我生 气 啦.. 直接看的答案,耻辱. 1 digit: 1~9 总共1×9个 2 digits: 10~99 总共2× ...

  7. 不区分大小写的in_array实现 thinkphp框架

    // 不区分大小写的in_array实现 function in_array_case($value,$array) { return in_array(strtolower($value),arra ...

  8. UVa1607 poj1435 UVaLive1686 Gates

    填坑系列(p.246) 由函数连续性得满足二分性 #include<cstdio> #include<cstring> #include<cstdlib> #inc ...

  9. Linux 操作系统位数(32or64)识别

    Linux 操作系统位数识别: LINUX 32位操作系统:Linux x86   i586  i386  i686 i... LINUX 64位操作系统:Linux x64x86_64  X64 . ...

  10. 自己在安装centos 系统时, 是使用英文安装 成功,现在系统语言为英语,如何设置为中文?

    作为一个linux菜鸟,遇到的问题可谓真多,在虚拟机VMware上安装好centos系统后,心里甚喜,也连上网络了. 一.遇到的问题 but,火狐浏览器浏览网页出现乱码,也不知道怎么解决?所有的中文都 ...