How come `MyClass.MyStaticMethod()` doesn't work, but `Serial.begin()` does? MyProject.ino:

#include "MyClass.h"

void setup()
{
  Serial.begin(9600);
  // MyClass.MyStaticMethod();
  MyClass::MyStaticMethod();
}


Both uncommented lines work, but the commented (when uncommented, of course) results in this error: expected unqualified-id before '.' token.

Now, I know this is because of the incorrect scope-resolution. Yet, how come Serial manages to call static functions without the need to use :: to correction to scope-resolution.

How come MyClass.MyStaticMethod() doesn't work, but Serial.begin() does?
. is used to call a method on a class instance whereas :: is used to call a static method within a class itself.

There is no Serial class - Serial is merely an instance of the HardwareSerial class.

#if defined(UBRRH) &amp;&amp; defined(UBRRL)
  HardwareSerial Serial(&amp;UBRRH, &amp;UBRRL, &amp;UCSRA, &amp;UCSRB, &amp;UCSRC, &amp;UDR);
#else
  HardwareSerial Serial(&amp;UBRR0H, &amp;UBRR0L, &amp;UCSR0A, &amp;UCSR0B, &amp;UCSR0C, &amp;UDR0);
#endif


If you want to use . then you have to instantiate your class and not use a static method:

class MyClass {
    static void myStaticMethod() {
    }
    void myMethod() {
    }
};

MyClass Fred;

// ... 

Fred.myMethod();
MyClass::myStaticMethod();