方法一:#include using namespace std;class A{public: static A* getInstance(); static void deleteInstance(A* pA);private: A() { cout using namespa...
分类:
编程语言 时间:
2014-08-19 12:17:24
阅读次数:
203
模板的部分特化
template
struct testClass
{
testClass(){cout<<"I,O"<<endl;}
};
template
struct testClass
{
testClass(){cout<<"T*,T*"<<endl;}
};
成员模板
template
class v
{
public:
template
void in...
分类:
编程语言 时间:
2014-08-18 23:35:23
阅读次数:
269
windows+vs情况下:在控制台上,cout能重定向到文件,cerr和clog不能。输出重定向到文件实际上就是一个管道的一头连输出流,另一头连文件输入流 cout具有自己的缓冲区,当缓冲区满或遇到endl会刷新终端(默认是屏...
分类:
其他好文 时间:
2014-08-18 22:12:53
阅读次数:
225
使用if defined endif根据平台的不同 来加载使用不同的方法#if defined(WIN32) std::cout<<"win32"<<std::endl;#elif defined(POSIX) std::cout<<"posix"<<std::endl;#endif
分类:
其他好文 时间:
2014-08-18 15:53:52
阅读次数:
150
参考:http://bbs.csdn.net/topics/370021520下面输出结果是多少?#include using namespace std;int g=0;templateint foo(T a){static int value = ++g;cout(3)(false)(2.2f)...
分类:
其他好文 时间:
2014-08-18 15:49:12
阅读次数:
168
水题一道- -暴力做法、打表都可以0ms AC。时间:0毫秒。#include#includeusing namespace std;int main(){ double ans=1, temp=1; int i=0; cout<<"n e"<<endl; cout<<...
分类:
其他好文 时间:
2014-08-17 21:11:22
阅读次数:
189
10、在16位机器上跑下列foo函数的结果是(B)(阿里2014笔试题)void foo(){int i = 65536;cout int main(){ __int16 a=65536; __int16 b=65535; __int16 c=65535+3; printf(...
分类:
其他好文 时间:
2014-08-17 16:43:52
阅读次数:
219
预测一下这道题的结果,注意unsigned与signed
#include
#include
using namespace std;
int arr[]={1,2,3,4,5};
int main(){
for(int i=-1;i<sizeof(arr)/sizeof(arr[0]) - 1;i++)
cout<<arr[i+1]<<endl;
}
sizeof()返回的值是无符号数,...
分类:
其他好文 时间:
2014-08-17 15:38:02
阅读次数:
251
string str("hello world");string *pstr = &str;cout << pstr[0] << endl;cout << *pstr << endl;本来以为psr[0]输出来的值是'h' 没有想到输出来的而是 hello world ,而且 *pstr输出的也是同...
分类:
其他好文 时间:
2014-08-17 15:32:32
阅读次数:
336
记忆式搜索#include using namespace std;int f(int a,int b){if(a>m>>n)cout<<f(m,n)<<endl;return 0;}
分类:
其他好文 时间:
2014-08-17 11:43:22
阅读次数:
177