第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

秋高手指點(diǎn),關(guān)于C++find_if算法以及bind函數(shù)部分的小問(wèn)題!

秋高手指點(diǎn),關(guān)于C++find_if算法以及bind函數(shù)部分的小問(wèn)題!

C++ C
largeQ 2021-10-14 21:11:55
請(qǐng)各位大俠過(guò)來(lái)幫忙看一看這個(gè)代碼有什么問(wèn)題?我寫(xiě)的代碼是:#include<iostream>//#include<sstream>//#include<numeric>#include<vector>#include<algorithm>#include <functional> using namespace std;vector<string> a = { "ssd", "bbblll", "ss", "wre", "sad", "adff", "asfdsgsdg", "wetrwetgsd" };bool check_size(const string &b, string::size_type sz){return b.size() >= sz;}void main(){auto wc = std::find_if(a.begin(), a.end(), std::bind(check_size, _1, 6));}編譯環(huán)境:visual studio 2013報(bào)錯(cuò):_1是未聲明的標(biāo)識(shí)符對(duì)比MSDN中對(duì)bind函數(shù)的使用,我也并沒(méi)有語(yǔ)法錯(cuò)誤呀?是什么問(wèn)題呢#include <functional> #include <algorithm> #include <iostream> using namespace std::placeholders; void square(double x) { std::cout << x << "^2 == " << x * x << std::endl; } void product(double x, double y) { std::cout << x << "*" << y << " == " << x * y << std::endl; } int main() { double arg[] = {1, 2, 3}; std::for_each(&arg[0], arg + 3, square); std::cout << std::endl; std::for_each(&arg[0], arg + 3, std::bind(product, _1, 2)); std::cout << std::endl; std::for_each(&arg[0], arg + 3, std::bind(square, _1)); return (0); } MSDN實(shí)例代碼運(yùn)行正確
查看完整描述

2 回答

?
慕婉清6462132

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超2個(gè)贊

_1 _2 ...定義在placeholders這個(gè)namespace,所以要用 using namespace std::placeholders;

查看完整回答
反對(duì) 回復(fù) 2021-10-17
  • 2 回答
  • 0 關(guān)注
  • 699 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)