I'm trying to populate a vector (words) within my class. I'm getting the error:
"Illegal reference to non-static member" in the function calls "words_to_vector" and "is_regular_address".
This worked before I moved things into classes.
The examples I'm finding on line don't seem to address this particular scenario.
Here is my code. Hopefully nothing pertinent was edited out. The vector "words" is referenced in LOTS of other places in my code, and I'm not YET getting an error on it.
In "words_to_vector" I'm populating the vector. In "is_regular_address", I'm just referring to it.
did you change the name of is_street_address and forget to update that change somewhere?
it does not exist here.
this error message is usually tied to trying to call a class method without an object.
instead of
variable.function(stuff);
you forget and just do
function(stuff);//error, nonstatic method call
Sorry, that should have read "is_regular_address". Typo on my part.
So, within the class, when I'm calling methods within it, do I use AddressCls::process_address(), or is there a better way. And is there a difference between calling private methods and public, when within the class.
not in the class:
variable.process_address()
or if inside the class
this->process_address() //long version
where
process_address() is understood to be 'this->' one //short version
within the class everything is public.
outside the class, if the method is private variable.function() will fail (error, attempt to call private method).
Thanks jonnin. that "this->" reference is what I needed.
To ne555, I did post the error message verbatim. It was in the post subject line. The line numbers aren't generated until after I post the code, so I will have to learn to go back in and edit my post to address the generated line numbers. The offending lines were 18 and 42. I see I also posted the error message verbatim within the body of the post. I'll try to highlight it next time.