can in this way be declared a global object class ?
Um, yeah! Basically, r
there is a global variable of type А
. C++ has inherited from C a certain syntax that enables you to declare variables after a class/struct definition. You can often see from C something like
struct vertex {
float x, y;
} my_vertex; // Declares a variable of type vertex
In C++, a struct
is the same as class
with the exception of the default access specifier.
You might have wondered what the semicolon is for after class definitions. So basically a class defined as
class my_class {};
with the braces immediately proceeded by a semicolon declares no variables.
You can also declare more than one variables by delimiting them with the comma operator.
class my_class {} x, y, z;