Please tell me if I have this right or not:
Not entirely, no.
A class is a template, like a cookie cutter. Once you have defined the class, you can use it to create as many objects/instances (cookies) as you like - all having the same capabilities.
The class, like Telegraph, needs a constructor, so instances can be created. The constructor is a special method that needs to be named the same as the class. There can be other methods in the class, that can have any name you like.
When you create instances of the class, the constructor will be executed. So,
Telegraph one;
Telegraph two;
creates two instances of the Telegraph class.
Each of those instances has all the methods and fields of the class. The methods are shared, but the fields are completely independent.
If the Telegraph class has a field:
unsigned long dit_length;
and a method:
void SetDitLength(unsigned long ditLength)
{
dit_length = ditLength;
}
then,
one.SetDitLength(10);
two.SetDitLength(10000);
will assign different values to the dit_length field of each instance.
So if I understand this correctly, my original thought, that requiring a class and its (primary?) object to have the same name seeming very restrictive as to how many objects a class could have, was completely unfounded.
There is no relationship whatsoever between a class name and the names of any instances of the class.
The only relationship between a class name and a method name is for two special functions - the constructor, which we have been talking about, which has the same name as the class, and the destructor, which we haven't talked about, which has the name of the class preceeded by a ~.
class Telegraph
{
public:
Telegraph(); // Constructor
~Telegraph(); // Destructor
// Any other public methods
// Any public fields (typically none)
private:
// Any private methods
// Any private fields
};