What's the difference between . and :: in methods?

Very basic, but you can write:-

Serial.begin(x) and LedSign::Set(x)

These are both method calls, yet one uses a period and the other a double colon. And for my own routines in the IDE it's the period notation. What's with that? Is it something to do with the hodgepodge Arduino language and pure C /C++?

It is C++. Serial is an object - an instance of class HardwareSerial. The method begin, can be called only on a class instance. LedSign is a class. Method Set in class LedSign is static. One of uses of :: is to call static methods of classes

But LedSign's Charliplexing.cpp or Charliplexing.h files do not contain the keyword "class". I did a search of them. I'm referring to the LOL shield library. Are you sure?

PS. I hate this half'n'half mix of C and C++ :angry:

cossoft:
PS. I hate this half'n'half mix of C and C++ :angry:

This is not a half and half mix. It's pure C++. Nothing more and nothing less.

cossoft:
But LedSign's Charliplexing.cpp or Charliplexing.h files do not contain the keyword "class". I did a search of them. I'm referring to the LOL shield library. Are you sure?

That library didn't pop right up in a search. Mind linking to it if you want help with it?

The difference between the two operators is just what was quoted above. :: is scope resolution. SO you would use it to get things that are static to a class or that are in a namespace other than the one you are in at that line.

The . is for methods and fields from a particular instance of an object.

I was looking into it to learn from this question :wink: This one possibly.

I'm not a C++ programmer, but I'm sure it has to do with the fact that it has a namespace LedSign.

Found something: Name visibility - C++ Tutorials

Delta_G:
That library didn't pop right up in a search. Mind linking to it if you want help with it?

Yeh, it's here. There doesn't seem to be the "class" keyword in the Charlieplexing.x files. I thought that a C++ class needed it...

in my answer I assumed that it is a class. other possibilities were struct, namespace or enum. it is a namespace

namespace LedSign
{
    extern void Init(uint8_t mode = SINGLE_BUFFER);
    extern void Set(uint8_t x, uint8_t y, uint8_t c = 1);
    extern void SetBrightness(uint8_t brightness);
#ifdef DOUBLE_BUFFER
    extern void Flip(bool blocking = false);
#endif
    extern void Clear(uint8_t c = 0);
    extern void Horizontal(uint8_t y, uint8_t c = 0);
    extern void Vertical(uint8_t x, uint8_t c = 0);
	extern uint8_t DisplayMode();
};

As for the C/C++ thing, I guess it's an old chestnut and someone may have discussed it previously on this forum :slight_smile:

But, it's clearly both from my perspective. avr/cores/arduino (in the official IDE) is full of C AND C++ source files. You see them being compiled in the IDE terminal window with gcc AND g++ output. Then add in the fact that one is the sub /super set of the other. And then add in the vast amount of compiler macros and #defines. I realise that Arduino is a huge success and I'm really glad, but from a programmer's perspective it's a bit of a cobbled together mess. I mean what's binary.h? Have you ever seen anyone use:-

snip...
#define B11 3
#define B011 3
#define B0011 3
#define B00011 3
#define B000011 3
#define B0000011 3
#define B00000011 3
...snip

And it's not just my opinion. Look at Stackoverflow. C and C++ are interchangeable in most of the questions /answers. See this link to an answer @ SO. So even the real programmers are a tad confused. I was going to have a bash with AVR Studio but that seems to be only for the privileged (Windows) users.

It looks like I'm currently struggling with namespaces making things appear like classes.

cossoft:
It looks like I'm currently struggling with namespaces making things appear like classes.

If it helps you can think of classes (and structs) as types (cuz they are)

int someValue;
SomeClass someInstance;

whereas namespaces simply define a scope; you cannot create an instance of a namespace.

Now I'm confused. The SO answer you linked was about the difference between the GNU C and C++ compilers. It wasn't about Arduino. I think the issue is that you might not understand the relationship between the two well and it has led you to think that something strange has been done here. It hasn't. This is how any number of programs are put together. I can't imagine writing C++ code without some of those C libraries. But that's not special to Arduino.

It's not a cobbled together mess. It's something you don't understand and you want to blame it. That's not fair. And it's not accurate either.

Everything you write in an Arduino sketch is C++. You never need to touch C except that for most things you do there's no real difference and you wouldn't be able to tell the two apart.