c++ - Getting error: missing template arguments before ‘(’ token -
i'm not sure what's wrong. i'm pretty new c++, don't see problems. i've read through bunch of other stack overflow pages, none of them seem address issue.
this terminal
joshs-macbook-pro:desktop josh$ g++ binarycompare.cpp binarycompare.cpp: in function ‘int main()’: binarycompare.cpp:9: error: missing template arguments before ‘(’ token
here's code.
#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; < a.length(); i++){ if(a[i] != b[i]){ if(a[i] == '1') return false; return true; } } return false; }
this example why using namespace std
not idea.
you've typo'd
if(greater("11", "00"))
which should
if(isgreater("11", "00"))
...and manage hit name of a class template defined in std
namespace you've imported whole-sale. thereby confusing error message.
Comments
Post a Comment