摘要:
按照默认规定,只有一个参数的构造函数也定义了一个隐式转换,将该构造函数对应数据类型的数据转换为该类对象,如下面所示:class String {String ( const char* p );//用C风格的字符串p作为初始化值//…}String s1 = “hello”;//OK 隐式转换,等价于String s1 = String(“hello”);但是有的时候可能会不需要这种隐式转换,如下:class String { String ( int n );//本意是预先分配n个字节给字符串String ( const char* p );//用C风格的字符串p作为初始化值//…}下面两种 阅读全文
posted @ 2012-09-29 14:11
瑞尼书苑
阅读(203)
评论(0)
推荐(0)
摘要:
1. 获取时间戳:time_t rawtime;time(&rawtime); //结果是时间戳2. 将时间戳转为 char* 类型的日期Www Mmm dd hh:mm:ss yyyy 1 /* ctime example */ 2 #include <stdio.h> 3 #include <time.h> 4 #include <iostream> 5 6 using namespace std; 7 8 int main () 9 {10 time_t rawtime;11 12 time ( &rawtime );13 printf 阅读全文
posted @ 2012-09-29 11:54
瑞尼书苑
阅读(8013)
评论(0)
推荐(0)
浙公网安备 33010602011771号