Rules for using underscores in C++ identifier names
Hi everyone! I just started learning C++ and noticed that in some code examples people use underscores at the beginning of variable names, like `_value` or `__internal`. I understand this is probably some naming style, but it seems to me that the compiler behaves strangely with such names.
For example, I tried writing this code:
```cpp
#include
class MyClass {
private:
int _value;
public:
MyClass(int v) : _value(v) {}
int getValue() const { return _value; }
};
int main() {
MyClass obj(42);
std::cout << obj.getValue() << std::endl;
return 0;
}
```
It compiled and worked fine, but then I tried doing this:
```cpp
int _main() {
return 0;
}
```
And the compiler gave a warning. And when I tried to
No answers yet.
Log in to leave an answer