1. #include <cstdio>
  2. #include <iostream>
  3. using namespace std;
  4. class TmpClass;
  5. void FuncScopeTmpClass(TmpClass s);
  6. class TmpClass{
  7. public:
  8. TmpClass():ident(i--){ printf("%2d ++\n", ident); }
  9. ~TmpClass() { printf("%2d --\n\n", ident); }
  10. int tick() { printf("%2d ||\n", ident); return i; }
  11. private:
  12. int ident;
  13. static int i;
  14. friend void FuncScopeTmpClass(TmpClass s);
  15. };
  16. int TmpClass::i = 20;
  17. TmpClass GetTempClass() { return TmpClass(); }
  18. void FuncScope(int s) { printf("%2d >>\n", s); }
  19. void FuncScopeTmpClass(TmpClass s) { printf("%2d <<\n", s.ident); }
  20. int main() {
  21. while(GetTempClass().tick()) {
  22. TmpClass a, b;
  23. GetTempClass(), GetTempClass(), FuncScope ( GetTempClass().tick() );
  24. FuncScope ( GetTempClass().tick() ), GetTempClass();
  25. FuncScope ( GetTempClass().tick() );
  26. FuncScopeTmpClass ( (GetTempClass(), GetTempClass(), GetTempClass()));
  27. break;
  28. }; return 0;
  29. }
  30. /* standard output
  31. 20 ++
  32. 20 ||
  33. 20 --
  34. 19 ++
  35. 18 ++
  36. 17 ++
  37. 16 ++
  38. 15 ++
  39. 15 ||
  40. 14 >>
  41. 15 --
  42. 16 --
  43. 17 --
  44. 14 ++
  45. 14 ||
  46. 13 >>
  47. 13 ++
  48. 13 --
  49. 14 --
  50. 12 ++
  51. 12 ||
  52. 11 >>
  53. 12 --
  54. 11 ++
  55. 10 ++
  56. 9 ++
  57. 9 <<
  58. 9 --
  59. 10 --
  60. 11 --
  61. 18 --
  62. 19 --
  63. */

cpp-variable-lifetime的更多相关文章

  1. jbpm的学习 出处http://blog.csdn.net/hxirui/article/details/1221911

    jbpm入门例子 分类: opensourse2006-09-14 11:30 37308人阅读 评论(22) 收藏 举报 jbpmhibernate数据库oraclemysqltransition ...

  2. jbpm入门样例

    1.      jBPM的简介 jBPM是JBOSS下的一个开源java工作流项目,该项目提供eclipse插件,基于Hibernate实现数据持久化存储.    參考 http://www.jbos ...

  3. 【LINT】cpplint修改版:自定义编码风格检查工具lint

    github:https://github.com/skullboyer/code-check Code Check 本仓介绍的内容涉及代码静态检查和编码风格检查 但主要放在编码风格检查,lint是基 ...

  4. OPEN CASCADE Multiple Variable Function

    OPEN CASCADE Multiple Variable Function eryar@163.com Abstract. Multiple variable function with grad ...

  5. vs2012 error c4996: This function or variable may be unsafe

    编译lua源码时,使用vs2012,遇到如下错误. 1>------ 已启动生成: 项目: 20130925, 配置: Debug Win32 ------ 1>  stdafx.cpp ...

  6. 配置OpenCV产生flann\logger.h(66): error C4996: 'fopen': This function or variable may be unsafe问题[zz]

    使用vs2012/2013配置opencv编译出现问题: 1>------ 已启动生成: 项目: Win32ForOpenCV245, 配置: Debug Win32 ------ 1> ...

  7. 安装solidity遇见的问题——unused variable 'returned'

    在编译安装solidity的过程中遇见了一个很奇怪的问题 webthree-umbrella/libethereum/libethereum/Executive.cpp: In member func ...

  8. [C/CPP系列知识] 那些程序C语言可以编译通过但C++无法编译成功 Write a C program that won’t compile in C++

    http://www.geeksforgeeks.org/write-c-program-wont-compiler-c/ 1) C++中在函数声明之前调用一个函数会引发错误,但是在C中有可能可以. ...

  9. Visual Studio 2015 编译错误【错误 C4996 'vsprintf': This function or variable may be unsafe. Consider using vsprintf_s instead. 】的解决方案

    错误提示信息: 错误 C4996 'vsprintf': This function or variable may be unsafe. Consider using vsprintf_s inst ...

  10. Run-Time Check Failure #2 - Stack around the variable 'ucPriKey' was corrupt

    Run-Time    Check    Failure    #2        一般是栈被破坏,你的代码可能有缓冲区溢出一类的问题. Run-Time Check Failure #2 - Sta ...

随机推荐

  1. Mina使用总结(二)Handler

    Handler的基本作用,处理接收到的客户端信息 一个简单的Handler实现如下: package com.bypay.mina.handler; import java.util.Date; im ...

  2. Java 输入输出流总结

    1. 运用BufferedInputStream 读取文件流和BufferedOutputStream写文件流: protected static void writeFile2(String inp ...

  3. Array.prototype.reduce 的理解与实现

    Array.prototype.reduce 是 JavaScript 中比较实用的一个函数,但是很多人都没有使用过它,因为 reduce 能做的事情其实 forEach 或者 map 函数也能做,而 ...

  4. P2418 yyy loves OI IV

    题目背景 某校2015届有两位OI神牛,yyy和c01. 题目描述 全校除他们以外的N名学生,每人都会膜拜他们中的某一个人.现在老师要给他们分宿舍了.但是,问题来了: 同一间宿舍里的人要么膜拜同一位大 ...

  5. [HNOI2005]汤姆的游戏

    嘟嘟嘟 直接O(n ^ 2)暴力判断就行了. 对于圆,判断该点和圆心的距离是否小于半径. 然而为啥我这么写编译不过: scanf("%lf%lf%lf%lf", &a[++ ...

  6. Hadoop学习之路(十二)分布式集群中HDFS系统的各种角色

    NameNode 学习目标 理解 namenode 的工作机制尤其是元数据管理机制,以增强对 HDFS 工作原理的 理解,及培养 hadoop 集群运营中“性能调优”.“namenode”故障问题的分 ...

  7. Cannot find module 'webpack/lib/node/NodeTemplatePlugin' 问题原因和解决方案

    当我配置了html-webpack-plugin 打包时报了这个错,查看了一下package.json发现没有webpack,说明使用了全局安装的webapck,导致的版本差异. 这里在本地安装web ...

  8. Python中乘法

    1.numpy乘法运算中"*"或multiply(),是数组元素逐个计算,具体代码如下: import numpy as np # 2-D array: 2 x 3 two_dim ...

  9. PAT乙级1032

    1032 挖掘机技术哪家强 (20 分)   为了用事实说明挖掘机技术到底哪家强,PAT 组织了一场挖掘机技能大赛.现请你根据比赛结果统计出技术最强的那个学校. 输入格式: 输入在第 1 行给出不超过 ...

  10. 目前.NET Core创建Windows Service比较好的一个开源框架:DasMulli.Win32.ServiceUtils

    新建一个.NET Core控制台程序,搜索并下载Nuget包:DasMulli.Win32.ServiceUtils GitHub 链接及使用指南 Write a windows service us ...