declaring string param in function problem

I thought I knew a little about functions, but this obviously proves otherwise.


I have a function that compares two strings and if they are the first is less than or equal to second returns a 1. Simple enough and doesn't even require a function, but I wanted to test my knowledge here since I am learning.

function looks something like:

1
2
3
4
5
int LessOrEqual(string str1, string str2){
bool check;
check = (str1<=str2);
return (check);
}


yet when I use this, It says str1 and str2 are not declared. why is this? i thought the whole point of using the (parameter 1, 2...) was that it declares the parameter there
have you included the string header file? and specified your using the namespace'd object?

e.g.
1
2
3
4
5
6
7
#include <string>

using std::string;

int LessOrEqual() {

}


FYI: strcmp() already does what your trying to write
ugh, though I did have those headers I had forgotten to put a final } after int main(). fixed.
Topic archived. No new replies allowed.