June 1st Monday (六月 一日 月曜日)
来源:互联网 发布:fragment数据传递 编辑:程序博客网 时间:2024/05/17 09:39
Oh! Template as parament is not supported in Visual C++ 6.0. Maybe it is so old. ^_^
I have to build the following codes in Visual C++ 2005.
//temparg.cpp
#include <iostream>
using namespace std;
template <class T>
class Stack {
int cnt;
T* bottom, *top;
public:
Stack() {
bottom = NULL;
top = NULL;
cnt = 0;
bottom = new T[10];
top = bottom;
}
~Stack() {
delete [] bottom;
}
bool push(T t) {
(*top) = t;
top++;
cnt++;
return (cnt>10) ? false : true;
}
bool pop(T& tr) {
top--;
cnt--;
tr = (*top);
return (cnt>=0) ? false : true;
}
};
template <template <typename T> class Thing>
class Crab
{
private:
Thing<int> s1;
Thing<double> s2;
public:
Crab() {};
// assumes the thing class has push() and pop() members
bool push(int a, double x) { return s1.push(a) && s2.push(x); }
bool pop(int & a, double & x){ return s1.pop(a) && s2.pop(x); }
};
int main()
{
Crab<Stack> nebula;
// Stack must match template <typename T> class thing
int ni;
double nb;
while (cin>> ni >> nb && ni > 0 && nb > 0)
{
if (!nebula.push(ni, nb))
break;
}
while (nebula.pop(ni, nb))
cout << ni << ", " << nb << endl;
cout << "Done./n";
return 0;
}
The example is about exit function.
//ex.c
#include <stdlib.h>
void ex1() {
printf("exit 1/n");
}
void ex2() {
printf("exit 2/n");
}
int main() {
atexit(ex1);
atexit(ex2);
return 0;
}
$ ./ex
exit 2
exit 1
From the above, you can know the order of calling your exit functions.
- June 1st Monday (六月 一日 月曜日)
- June 8th Monday (六月 八日 月曜日)
- June 1th Friday (六月 一日 金曜日)
- June 11th Monday (六月 十一日 月曜日)
- June 25th Monday (六月 二十五日 月曜日)
- June 15th Monday (六月 十五日 月曜日)
- June 22th Monday (六月 二十二日 月曜日)
- June 29th Monday (六月 二十九日 月曜日)
- 2008 September 1st Monday (九月 一日 月曜日)
- June 4th Monday (六月 四日 日曜日)
- February 1st Monday 2010
- 六月一日
- 课堂笔记六月一日
- 2008 March 31th Monday (三月 三十一日 月曜日)
- March 1st Thursday (三月 一日 木曜日)
- April 1st Wednesday (四月 一日 水曜日)
- July 1st Wednesday (七月 一日 水曜日)
- June 2st - Blog - Live
- C# 2005 换肤软件IrisSkin2使用笔记。
- 中国财富加速集中
- C语言读写文件
- LINQ to SQL语句
- “欣赏”无线通讯技术
- June 1st Monday (六月 一日 月曜日)
- Linux下更改Firefox的默认主页
- June 2nd Tuesday (六月 二日 火曜日)
- MFC CString 的用法
- 告诉你什么是“五险一金”
- 学习总结
- 功能身退
- June 3th Wednesday (六月 三日 水曜日)
- 使用位图法判断整形数组是否存在重复 (待续)