何が悪いのかわからない。私はC ++にかなり慣れていませんが、問題はありません。他のスタック オーバーフロー ページをたくさん読みましたが、どれも私の問題に対処していないようです。
これは端末から
Joshs-MacBook-Pro:desktop Josh$ g++ BinaryCompare.cpp
BinaryCompare.cpp: In function ‘int main()’:
BinaryCompare.cpp:9: error: missing template arguments before ‘(’ token
これがコードです。
#include <iostream>
#include <string>
using namespace std;
bool isGreater(string a, string b);
int main (){
if(greater("11", "00"))
cout << "hello"<<endl;
return 0;
}
bool isGreater(string a, string b){
if(a.length() > b.length() ) return false;
if(a.length() < b.length() ) return true;
for(int i= 0; i < a.length(); i++){
if(a[i] != b[i]){
if(a[i] == '1') return false;
return true;
}
}
return false;
}