C++新手求大佬知道 谢谢

「已注销」 2017-04-19 11:36:21

【求助帖】请及时确认最佳答案,下次提问时可以得到更多关注,问题可以更快解决
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <string>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
struct function//用途
{
string time;//日期
string money;//金额
string procession;//用途
string account;
string name;
struct function *next;
};
struct message
{
string account;//个人信息账号
string name1;//名字
string mima;//密码
struct function F;
struct message *next;//指向下一个结点
};
double getmoney(string t)
{
double sum = 0;
int flag = 1,j = 1;
if(t.at(0) == '-'||t.at(0) == '+')
{
int i = 1;
for(i = 1; i < t.size(); i++)
{
if(flag == 0)
{
sum = sum + (t.at(i)-'0')*pow(0.1,j);
j++;
}
if(t.at(i) == '.')
{
flag = 0;
}
if(flag == 1)
{
sum = sum*10+(t.at(i)-'0');
}
}
if(t.at(0) == '-')
{
sum*=-1;
}
}
else
{
int i = 0;
for(i = 0; i < t.size(); i++)
{
if(flag == 0)
{
sum = sum + (t.at(i)-'0')*pow(0.1,j);
j++;
}
if(t.at(i) == '.')
{
flag = 0;
}
if(flag == 1)
{
sum = sum*10+(t.at(i)-'0');
}
}
}
return sum;
}
bool cmp(struct function* a,struct function* b)
{
double a1=0,b1=0;
a1 = getmoney(a->money);
b1 = getmoney(a->money);
if(fabs(a1) > fabs(b1))
{
return true;
}
else
{
return false;
}

}
void sortprepare(struct message T ,string chose5)
{
if(chose5 == "1")//按金额排行
{
vector<struct function*> sq;
struct message*q;
q = T.next;
while(q)
{
struct function* f;
f = q->F.next;
while(f)
{
sq.push_back(f);
f = f->next;
}
q = q->next;
}
vector<struct function*>::iterator start;
start = sq.begin();
sort(sq.begin(),sq.end(),cmp);
}

}
int main()
{struct message T;
sortprepare(T,"5");
}
问题求助
这里的sort为什么有语法错误啊
解决语法错误即可
谢谢各位了
一下是错误
谢谢了
E:\360downloads\23e2e\main.cpp|997|error: no matching function for call to 'sort(__gnu_cxx::__normal_iterator<function**, std::vector<function*, std::allocator<function*> > >, __gnu_cxx::__normal_iterator<function**, std::vector<function*, std::allocator<function*> > >, <unresolved overloaded function type>)'|
...全文
148 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zycxnanwang 2017-04-20
  • 打赏
  • 举报
回复
问题估计出在你给结构体指针排序,建议直接用结构体啊
棉猴 2017-04-20
  • 打赏
  • 举报
回复
windows XP + VS2008运行没有错误
paschen 版主 2017-04-20
  • 打赏
  • 举报
回复
VS2015上测试没有问题

64,637

社区成员

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

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