Today " :: " is called a 'double scope operator'? yes? How does it work, got real tired of trying to find and make sense of it...
Doc
Today " :: " is called a 'double scope operator'? yes? How does it work, got real tired of trying to find and make sense of it...
Doc
Example?
Here:
class foo
{
void bar ();
};
void foo::bar ()
{
Serial.print ("bar");
}
void setup () {}
void loop () {}
In this example the function bar "belongs" to foo, so the scope operator says bar is part of foo.
I think I see is it an ability to access something private in scope public, a handle or window into a variable declared private in scope? and if so why?
Doc
It's nothing to do with public and private. It is scope. For example, if you have John Smith and John Edison, you might write:
Smith::John
or:
Edison::John
One is John in the Smith family and one is John in the Edison family. It is scoping the name John.
Dead silence except feet moving in direction of book shelf, Thank you sir it is apparent I don't know enough of the subtleties of Scope so off I go, nice thing about that is one never knows what one will discover...
Doc
I gave it some thought and looked at tthe line from tinyGPS again and this line started to make sense all except INVALID which sorts left my in my head again and that for C is a big empty and lonely place... So?
print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 9, 5);
Doc
might be accessing an enumeration field :: not really necessary unless there are name conflicts:
enum TinyGPS{
GPS_INVALID_F_ANGLE,
...,
...
};
or a struct static member
struct TinyGPS{
static int GPS_INVALID_F_ANGLE;
};
That field is defined inside the class:
class TinyGPS
{
public:
...
static const float GPS_INVALID_F_ANGLE, GPS_INVALID_F_ALTITUDE, GPS_INVALID_F_SPEED;
It is instantiated here:
const float TinyGPS::GPS_INVALID_F_ANGLE = 1000.0;
Since it is inside the class you need the scope operator to get at it.
More precisely, because it is a static member, you need to do that. If it was a class (non-static) member you would use the "dot" notation for an instance of the class.
Wow,, Thank you as always you leave me knowing 'less' than I did before, knowing that at least I am a little bit less dumb... and also every time more questions to follow up... I decided that I would learn to truly manipulate the great library's and the others as necessary in finishing the sketch for my full time fun project, it's a ball from buying something to learning how to use the basics to assembling it, both code and hardware while being as thorough as I know how and all the time looking around for what I missed... Thanks, Nick
Doc
This is precisely why the type cast question I asked you the other day? night for me about 1:30A but remember This?
tlcd.print(static_cast(hour + 7)); tlcd.print(":"); tlcd.print(static_cast(minute))
The line I quoted last was what this guy tried to do... in another similar area of the code in other words your answer was the correction of his mistake.
and the reason the whole piece of code was no good, maybe in old K&R code?
I think...
Doc