常用的c_c++代码
2012-02-27 08:03
162 查看
#include <iostream>
#include <time.h>
int main()
{
time_t curtime=time(0);
tm tim =*localtime(&curtime);
int day,mon,year;
day=tim.tm_mday;
mon=tim.tm_mon;
year=tim.tm_year;
std::cout<<year+1900<<"年"<<mon+1<<"月"<<day<<"日"<<std::endl;
system("pause");
return 0 ;
}
////对传入的不定长的参数进行处理,一般用于打印日志中
writelog(char *format,...)
{
va_list args;
char buf[4096];
memset(buf,0,4096);
va_start(args, format);
vsprintf_s(&buf[strlen(buf)], 4096, format, args);
va_end(args);
string strResult(buf);
..... /////以下进行其它的处理
}
//////A,B类互相引用的方式
////A.h 文件中:
class B; /////注意A.h 不可以包含B.h
....
void fun(B *pB) ;
/////end of A.h
/////A.cpp 文件中:
#include "B.h"
void fun(B *pB)
{ ....};
... /////end of A.cpp
//////B.h 文件中
#include "A.h"
A *m_pA;
.....
/////end of B.h
//////B.cpp 文件中
#include "B.h"
....
m_pA = xxxx;
///////end of B.cpp
#include <time.h>
int main()
{
time_t curtime=time(0);
tm tim =*localtime(&curtime);
int day,mon,year;
day=tim.tm_mday;
mon=tim.tm_mon;
year=tim.tm_year;
std::cout<<year+1900<<"年"<<mon+1<<"月"<<day<<"日"<<std::endl;
system("pause");
return 0 ;
}
////对传入的不定长的参数进行处理,一般用于打印日志中
writelog(char *format,...)
{
va_list args;
char buf[4096];
memset(buf,0,4096);
va_start(args, format);
vsprintf_s(&buf[strlen(buf)], 4096, format, args);
va_end(args);
string strResult(buf);
..... /////以下进行其它的处理
}
//////A,B类互相引用的方式
////A.h 文件中:
class B; /////注意A.h 不可以包含B.h
....
void fun(B *pB) ;
/////end of A.h
/////A.cpp 文件中:
#include "B.h"
void fun(B *pB)
{ ....};
... /////end of A.cpp
//////B.h 文件中
#include "A.h"
A *m_pA;
.....
/////end of B.h
//////B.cpp 文件中
#include "B.h"
....
m_pA = xxxx;
///////end of B.cpp
相关文章推荐
- 常用算法经典代码(C++版)
- C++中一些常用的容器的方法小结(附详细代码及详细注释)
- new用法之常用格式c++代码
- C++常用的读写文件代码
- C++_文本文件读写常用代码
- 《转载》常用算法经典代码(C++版)
- new用法之常用格式c++代码
- 常用的C/C++代码格式优化工具有两个,一是老牌的indent,再一个就是astyle了。
- 常用算法经典代码(C++版)
- c++ 常用代码片段
- C++ 常用代码001 IsValidFileName VC/MFC 判断有效文件名
- Cocos2dx 3.x C++人员过渡Lua的常用代码总结
- C++使用Mysql的详细步骤及各个常用方法的代码演示:select,insert,update,delete
- 常用算法经典代码(C++版)
- c++常用代码
- ZZ 常用算法经典代码(C++版)
- C&C++常用小函数 代码
- 常用算法经典代码(C++版)
- emacs常用配置-注释/反注释C++代码
- 常用算法经典代码(C++版)