在write_ini.h中定义了一个函数write(),
分别在mainDlg.cpp和online.cpp中使用,但老是提示在
online.cpp中不认识write(),而在mainDlg.cpp中却可以,
在两个源文件中我都包含了write_ini.h.非常的迷惑,
请高手指点,谢谢最后我改为在write_ini.h中定义了一个类writ,把write()
封装在里面,就都能使用了
分别在mainDlg.cpp和online.cpp中使用,但老是提示在
online.cpp中不认识write(),而在mainDlg.cpp中却可以,
在两个源文件中我都包含了write_ini.h.非常的迷惑,
请高手指点,谢谢最后我改为在write_ini.h中定义了一个类writ,把write()
封装在里面,就都能使用了
Source File下有
mainDlg.cpp
online.cpp
...等几个类源文件,
而在Header File下有:
write_ini.h
...
等几个头文件,
而我自己定义的write()函数就在这个头文件里,
现在想在mainDlg.cpp和online.cpp下都能使用write()函数,
我已经在mainDlg.cpp和online.cpp里都#include write_ini.h了,
但是提示online.cpp里不认识write()!!!
而mainDlg.cpp却没有提示所以很迷惑!
{
int k;
CString temp1,tempS,str;
CString path=get_path();
CTime time;
time=CTime::GetCurrentTime(); //获取当前时间
temp1.Format("%.4d",time.GetYear()); //得到时间的年份,并赋值给字符串temp1
str=temp1.Mid(2,2); //取字符串的某一段,前面一个2表示从第三个位置开始取,后面一个表示去两个字符
temp1.Format("%.2d",time.GetMonth());
str+=temp1;
temp1.Format("%.2d",time.GetDay());
str+=temp1;
path+="\\log\\";
path+=str;
path+=".log";//取每天的时间生成一个文件,后缀名为.log
k=::GetPrivateProfileInt("刷卡总次数","总次数",0,path);
k++;
tempS.Format("%.8d",k);
::WritePrivateProfileString("刷卡总次数","总次数",tempS,path); //先写总次数
::WritePrivateProfileString("刷卡记录",tempS,message,path); //后写刷卡记录,则刷卡记录可以自动换行,反之则要通过数组来实现
}这个就是write_ini.h中定义的write函数,楼上兄台看看有什么问题,拜托了
然后在 三个 cpp文件中都包含 write_ini.h 试试。#if !defined MY_WRITE_INI_H
#define MY_WRITE_INI_H
...
void write(CString message);
...
#endif //MY_WRITE_INI_H
#define
...
void write()
....
#endif
// wirte.h
//in main.cpp
#include "wirte_in.h"
//in wite_line.cpp
#include "wirte_in.h"