If you want to ask me what is the worst habit I found in C ++?
I have to tell you: it is the habit of using namespace STD;
Sometimes you will find that using namespace STD can save you a lot of time to avoid STD: cout; STD: CIN; STD: Endl, STD: String, etc,
I was fortunate to have discovered this secret for a while, but now I have discovered how fatal this secret is.
A few days ago, I used the simplest program to construct a read_info class and perform >>and <Operator overloading.
When I write a program, the habits are as follows:
# Include <iostream>
Using namespace STD;
Class read_info {
.......
};
When read_info.cpp calls read_info.h, the system prompts that the private member cannot be accessed.
Why am I surprised? Why can't I access my own members.
Later, we found that the most harmful tool is using namespace STD;
Of course, I have not made it clear: Why does it affect access by members?
But I must give up on this habit.