How to resolve Error: #276: name followed by "::" must be a class or namespace name ?
-
Hi when i am writing code like below i am getting no error:
for (short int i =0 ; i<sqliteManagerMap.size();i++)
{
delete sqliteManagerMap[i];
}
But when i put below code instead itfor(std::map<int,SqliteManagerBGSync*>::iterator it = sqliteManagerMap::begin(); it != sqliteManagerMap::end(); ++it) { delete it->second; }
i am getting below 2 error:
"src\SqliteManagerBGSync.cpp", line 32: Error: #276: name followed by "::" must be a class or namespace name
for(std::map<int,SqliteManagerBGSync*>::iterator it = sqliteManagerMap::begin(); it != sqliteManagerMap::end(); ++it)
^
"src\SqliteManagerBGSync.cpp", line 32: Error: #276: name followed by "::" must be a class or namespace name
for(std::map<int,SqliteManagerBGSync*>::iterator it = sqliteManagerMap::begin(); it != sqliteManagerMap::end(); ++it)Just for your information: my map is declared in .h filelike below :
static std::map<int,SqliteManagerBGSync *> sqliteManagerMap;
How to resolve above error ?
-
Hi when i am writing code like below i am getting no error:
for (short int i =0 ; i<sqliteManagerMap.size();i++)
{
delete sqliteManagerMap[i];
}
But when i put below code instead itfor(std::map<int,SqliteManagerBGSync*>::iterator it = sqliteManagerMap::begin(); it != sqliteManagerMap::end(); ++it) { delete it->second; }
i am getting below 2 error:
"src\SqliteManagerBGSync.cpp", line 32: Error: #276: name followed by "::" must be a class or namespace name
for(std::map<int,SqliteManagerBGSync*>::iterator it = sqliteManagerMap::begin(); it != sqliteManagerMap::end(); ++it)
^
"src\SqliteManagerBGSync.cpp", line 32: Error: #276: name followed by "::" must be a class or namespace name
for(std::map<int,SqliteManagerBGSync*>::iterator it = sqliteManagerMap::begin(); it != sqliteManagerMap::end(); ++it)Just for your information: my map is declared in .h filelike below :
static std::map<int,SqliteManagerBGSync *> sqliteManagerMap;
How to resolve above error ?
@Qt-embedded-developer said in How to resolve Error: #276: name followed by "::" must be a class or namespace name ?:
for(std::map<int,SqliteManagerBGSync*>::iterator it = sqliteManagerMap::begin(); it != sqliteManagerMap::end(); ++it)
You should really learn C++!
for(std::map<int,SqliteManagerBGSync*>::iterator it = sqliteManagerMap.begin(); it != sqliteManagerMap.end(); ++it)
begin() and end() are non-static methods!
You have even examples in https://en.cppreference.com/w/cpp/container/map/begin
Do you actually read documentation? -
@Qt-embedded-developer said in How to resolve Error: #276: name followed by "::" must be a class or namespace name ?:
for(std::map<int,SqliteManagerBGSync*>::iterator it = sqliteManagerMap::begin(); it != sqliteManagerMap::end(); ++it)
You should really learn C++!
for(std::map<int,SqliteManagerBGSync*>::iterator it = sqliteManagerMap.begin(); it != sqliteManagerMap.end(); ++it)
begin() and end() are non-static methods!
You have even examples in https://en.cppreference.com/w/cpp/container/map/begin
Do you actually read documentation?@jsulm Your response could've been better, but I know not everyone is an expert at communication. Your tone is the reason new programmers are afraid to ask questions. We were all new at one point in time, and there's no need to act this way when a question is posted.
Maybe someone doesn't know where/how to find documentation. Or maybe, and this is crazy, but maybe some people prefer to ask a real human a simple question instead of looking through pages of technical documentation that, as a new programmer, they may not be able to follow.
Perhaps this person should have read the documentation first, but there are ways to respond better.
Instead of "You should really learn C++!", you could've said: "Congratulations on learning C++. It's an excellent language."
The lines "begin() and end() are non-static methods!
You have even examples in https://en.cppreference.com/w/cpp/container/map/begin
Do you actually read documentation?"
could be reworded to
"The reason this doesn't work is because begin() and end() are non-static methods. A great way to start is to look at documentation, like the examples here: https://en.cppreference.com/w/cpp/container/map/begin. That website is a great starting point for all questions regarding C++, but if you're ever stuck again after checking it out, post again for some help."See how that conveys the same information but in a different tone that is more welcoming to a novice programmer? Again, I know not everyone is an expert communicator, but if you'd like some good books on the subject, check out this list: Removed unrelated, potential spam link [@J-Hilk]
-
If @jsulm didn't say it I would have...We spend too many hours on this forum hand-holding people who are often lazy and don't/won't take responsibility to use proper internet research techniques, or for some reason that escapes me, seem to take the too common managment attitude "it's just software. How hard can it be?" which is kind of a slap in the face to those of us who have been coding for 20,30,40 years, and who prefer the model "if ya wanna play online then you need to have a thick skin and grow a pair".
Basic Qt/C++ truths: productive Qt/C++ expects a certain amount of sophistication and computer science background before ever reading an example program...assuming they actually take the time to read the examples. How many times have I read "what function can I use to do such and such?" to which any shlep on the internet shoudl very well expect the common response RTFM!
Sorry, no tolerance for dumming down the herd. We're helpful, but we demand a certain amount of commitment and when we dont' see it we tend to identify the offenders and become less patient with them.
-
@jsulm Your response could've been better, but I know not everyone is an expert at communication. Your tone is the reason new programmers are afraid to ask questions. We were all new at one point in time, and there's no need to act this way when a question is posted.
Maybe someone doesn't know where/how to find documentation. Or maybe, and this is crazy, but maybe some people prefer to ask a real human a simple question instead of looking through pages of technical documentation that, as a new programmer, they may not be able to follow.
Perhaps this person should have read the documentation first, but there are ways to respond better.
Instead of "You should really learn C++!", you could've said: "Congratulations on learning C++. It's an excellent language."
The lines "begin() and end() are non-static methods!
You have even examples in https://en.cppreference.com/w/cpp/container/map/begin
Do you actually read documentation?"
could be reworded to
"The reason this doesn't work is because begin() and end() are non-static methods. A great way to start is to look at documentation, like the examples here: https://en.cppreference.com/w/cpp/container/map/begin. That website is a great starting point for all questions regarding C++, but if you're ever stuck again after checking it out, post again for some help."See how that conveys the same information but in a different tone that is more welcoming to a novice programmer? Again, I know not everyone is an expert communicator, but if you'd like some good books on the subject, check out this list: Removed unrelated, potential spam link [@J-Hilk]
@mikez
Then I suggest you join this forum on a permanent basis and type in as much explanation as you wish, phrased in whatever way you consider suitable, to every question asked rather than complaining about what @jsulm has written.This is a forum for Qt help. It is not a forum to teach or hand-hold people through learning C++, Python, programming etc. There are plenty of forums out there for just that, but not this one.
-
@jsulm Your response could've been better, but I know not everyone is an expert at communication. Your tone is the reason new programmers are afraid to ask questions. We were all new at one point in time, and there's no need to act this way when a question is posted.
Maybe someone doesn't know where/how to find documentation. Or maybe, and this is crazy, but maybe some people prefer to ask a real human a simple question instead of looking through pages of technical documentation that, as a new programmer, they may not be able to follow.
Perhaps this person should have read the documentation first, but there are ways to respond better.
Instead of "You should really learn C++!", you could've said: "Congratulations on learning C++. It's an excellent language."
The lines "begin() and end() are non-static methods!
You have even examples in https://en.cppreference.com/w/cpp/container/map/begin
Do you actually read documentation?"
could be reworded to
"The reason this doesn't work is because begin() and end() are non-static methods. A great way to start is to look at documentation, like the examples here: https://en.cppreference.com/w/cpp/container/map/begin. That website is a great starting point for all questions regarding C++, but if you're ever stuck again after checking it out, post again for some help."See how that conveys the same information but in a different tone that is more welcoming to a novice programmer? Again, I know not everyone is an expert communicator, but if you'd like some good books on the subject, check out this list: Removed unrelated, potential spam link [@J-Hilk]