As indicated, you can't do that.
The code
int rfind( const char*, int position = this->str_len );
has an out-of-scope variable reference:
this
simply isn't defined outside the member functions... and the prototype is
outside the member functions.
Also, you need to be careful how you bite the hands feeding you. When you post here for advice, and you are given an answer, rather than get angry about our missing the point, you might want to consider that
you are missing the point.
Unfortunately, your posts above are so heavily edited that I (nor anyone else) cannot figure out exactly what was written and what wasn't. Your first post was not sufficiently clear; it is entirely reasonable that someone could interpret it as your having difficulty with the syntax as it is posted -- to which the reasonable response is that the syntax is not correct. But to answer the bolded question directly:
no, you cannot do that as the language does not permit it. (You cannot use
this
out of scope.)
However, I
can say that the aggressive attitude you have demonstrated in your posts (not just this thread) when learning something new to you is a fair put-off... Who wants to help someone who is rude about the help he receives? For example:
member variable and member mean the same thing. |
They most certainly do
not. Class members can be data, functions, nested types, and enumerators. You can first assume that any confusion people have about your use of the word "member" is likely because you are using the word incorrectly or without sufficient precision.
As for the -1 thing, an example from the STL might help. The standard string classes (
std::
basic_string) defines invalid values using the base class constant value
npos. Essentially:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
template<typename _CharT, typename _Traits, typename _Alloc>
class basic_string
{
...
public:
static const size_type npos = static_cast<size_type>(-1);
...
public:
...
basic_string&
erase(size_type __pos = 0, size_type __n = npos);
};
|
(This is from the GCC STL: bits/basic_string.h)
This example shows how to create a constant name that represents the end of a string, and how you can use it in your member function prototypes.
Inside the
std::
string::
erase() function, however, you still have to check to see if the '__n' argument is greater than the string length and adjust it to fit.
Hope this helps.