Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. How to resolve Error: #276: name followed by "::" must be a class or namespace name ?
QtWS25 Last Chance

How to resolve Error: #276: name followed by "::" must be a class or namespace name ?

Scheduled Pinned Locked Moved Solved C++ Gurus
6 Posts 6 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on 22 Feb 2022, 05:58 last edited by Qt embedded developer
    #1

    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 it

    for(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 ?

    J 1 Reply Last reply 22 Feb 2022, 06:12
    0
    • Q Qt embedded developer
      22 Feb 2022, 05:58

      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 it

      for(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 ?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 22 Feb 2022, 06:12 last edited by jsulm
      #2

      @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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply 24 Mar 2023, 23:53
      4
      • J jsulm
        22 Feb 2022, 06:12

        @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?

        M Offline
        M Offline
        mikez
        wrote on 24 Mar 2023, 23:53 last edited by J.Hilk
        #3

        @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]

        J J 2 Replies Last reply 25 Mar 2023, 08:38
        0
        • K Offline
          K Offline
          Kent-Dorfman
          wrote on 25 Mar 2023, 06:33 last edited by Kent-Dorfman
          #4

          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.

          1 Reply Last reply
          2
          • M mikez
            24 Mar 2023, 23:53

            @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]

            J Offline
            J Offline
            JonB
            wrote on 25 Mar 2023, 08:38 last edited by JonB
            #5

            @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.

            1 Reply Last reply
            2
            • M mikez
              24 Mar 2023, 23:53

              @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]

              J Offline
              J Offline
              J.Hilk
              Moderators
              wrote on 25 Mar 2023, 09:17 last edited by
              #6

              @mikez I'm German, I call it as I see it. No amount flowery words will transform a turd into a biscuit.

              That said, I removed the unrelated potential spam link from your post. My spam senses are tingling, so I'll keep a close watch.


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved