C++ 编译动态链接库时出错,求助!谢谢

mhlbbl 2007-01-04 11:27:06
头文件
// myTime.h
__declspec(dllexport) void Func1();
__declspec(dllexport) void Func2();
__declspec(dllexport) bool timeCompare(string time1,string time2);


cpp;
// myTime.cpp
#include "myTime.h"
#include <string>
//#include <iostream>
void Func1() {
// std::cout << "Tsinghua\n";
}
void Func2() {
// std::cout << "C++ OOP\n";
}
bool timeCompare(string time1,string time2){
//比较两个string类的时间大小
int time1Lenth = time1.size();
int time2Lenth = time2.size();

if(time1Lenth > time2Lenth){
for(int i=0;i<time1Lenth - time2Lenth; i++)
if (time1[i] != '0')
return true;
}

if(time1Lenth < time2Lenth){
for(int i=0;i<time1Lenth - time2Lenth; i++)
if (time2[i] != '0')
return false;
}

if(time1Lenth == time2Lenth){
for(int i=0;i< time1Lenth ;i++){
if(time1[i] > time2[i])
return true;
if(time1[i] < time2[i])
return false;

}
if(time1[time1Lenth-1]==time2[time2Lenth-1])
return true;
return false;

}
return false;
}
...全文
262 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
拿节 2007-01-04
  • 打赏
  • 举报
回复
up
taodm 2007-01-04
  • 打赏
  • 举报
回复
bool timeCompare(char * time1_c,char * time2_c){
string time1(time1_c), time2(time2_c);
即可
mhlbbl 2007-01-04
  • 打赏
  • 举报
回复
taodm(taodm)
string 和char*怎么转换
wonxlei 2007-01-04
  • 打赏
  • 举报
回复
路过
mhlbbl 2007-01-04
  • 打赏
  • 举报
回复
能否帮我编译通过
mhlbbl 2007-01-04
  • 打赏
  • 举报
回复
改用char*变动很大,函数也得改
我是初学,请高手给出点具体的回答
taodm 2007-01-04
  • 打赏
  • 举报
回复
啥错?
你用了string作为参数,必须使用扩展dll模式。而且无法跨编译器使用这个dll。
改用char *
popy007 2007-01-04
  • 打赏
  • 举报
回复
function definition的时候也需要加上__declspec(dllexport)
mhlbbl 2007-01-04
  • 打赏
  • 举报
回复
解决了,谢谢
mhlbbl 2007-01-04
  • 打赏
  • 举报
回复
帮人帮到底,救人救个活,谢谢
mhlbbl 2007-01-04
  • 打赏
  • 举报
回复
请明示,不懂啊
跟常数有关吗?
taodm 2007-01-04
  • 打赏
  • 举报
回复
这个问题该你自己搞定了。认真看编译错误的提示。
mhlbbl 2007-01-04
  • 打赏
  • 举报
回复
taodm(taodm) 报错了
Mybank.cpp(128) : error C2664: 'timeCompare' : cannot convert parameter 1 from '
const char *' to 'char *'
Conversion loses qualifiers


我是想把原来string的改为char*类
调用的是后 把string 的 time1 和 time2 改为 char*类

if(timeCompare(cos.begin.c_str(),readyTime.c_str()))

谢谢

taodm 2007-01-04
  • 打赏
  • 举报
回复
time1.c_str()
mhlbbl 2007-01-04
  • 打赏
  • 举报
回复
string转化为char * 呢?

64,648

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧