I am learning C++. Now I don't fully understand what this does
Some_Class::Some_Class {
etc...
}
I would do some research for myself, but I'm not sure where to begin or what's it called. Help would be appreciated.
The Scope Resolution Operator in C++ Two colons (::) are used in C++ as a scope resolution operator. This operator gives you more freedom in naming your variables by letting you distinguish between variables with the same name.
a notation for equality of ratios. a scope resolution operator, in computer programming languages.
The double colon (::) operator, also known as method reference operator in Java, is used to call a method by referring to it with the help of its class directly. They behave exactly as the lambda expressions.
It means pseudo element selector. It means the element to the right doesn't exist in the normal DOM, but can be selected. A pseudo-element is made of two colons (::) followed by the name of the pseudo-element. Source.
The :: resolves either a class or namespace.
For example
namespace test1 { int i = 0; }
cout << test1::i << endl;
or
class test2 {
public:
static int i = 0;
};
// after in
cout << test2::i << endl;
You can also add this:
using namespace test1;
cout << i << endl;
There's no way to say what it is, since the "code" you posted is invalid and ambiguous.
It could be a nested class definition made in out-of-class fashion. When you define nested classes, you can immediately define the inner class inside, as in
class Some_Class { // <- definition of the outer class
...
class SomeClass { // <- definition of the inner class
...
};
...
};
Or, if you prefer, you can only declare the nested class inside, and move the actual definition outside
class Some_Class { // <- definition of the outer class
...
class SomeClass; // <- declaration of the inner class
...
};
class Some_Class::SomeClass { // <- definition of the inner class
...
};
However, for that it has to begin with class/struct
, which is not present in what you posted.
Or it could be a definition of member function SomeClass
of class Some_Class
.
class Some_Class {
...
void SomeClass(int i); // <- declaration of member function
...
};
void Some_Class::SomeClass(int i) // <- definition of member function
{
...
}
But for that it has to include return type and parameter list.
Or it could be a definition of a static member with {}
-enclosed initializer
class Some_Class {
...
static int SomeClass;
...
};
int Some_Class::SomeClass { 42 };
But for that it has to include static member's type.
In other words, there's no way to say what it is you posted and what your question is really about.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With