Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. access violation with std::map (VS2015)

access violation with std::map (VS2015)

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 Posters 0 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Member 8534035
    wrote on last edited by
    #1

    I need a sorted list of strings with some additional information for each entry, so I thought about to use std::map I am doing just simple things: Definition:

    typedef std::map tTABMNEMO;
    tTABMNEMO TabMnemo;

    and in constructor of using class I am calling firstly:

    TabMnemo.clear();

    already this first access (in constructor of using class) causes an access violation. any idea, what could be wrong? Do I need to initialize anyhow? maybe it is because of my program structure? this map is defined globally outside of the class and all the member functions of the using class are static functions!

    D CPalliniC 2 Replies Last reply
    0
    • M Member 8534035

      I need a sorted list of strings with some additional information for each entry, so I thought about to use std::map I am doing just simple things: Definition:

      typedef std::map tTABMNEMO;
      tTABMNEMO TabMnemo;

      and in constructor of using class I am calling firstly:

      TabMnemo.clear();

      already this first access (in constructor of using class) causes an access violation. any idea, what could be wrong? Do I need to initialize anyhow? maybe it is because of my program structure? this map is defined globally outside of the class and all the member functions of the using class are static functions!

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Member 8534035 wrote:

      TabMnemo.clear();

      Have you tried:

      try
      {
      TabMnemo.clear();
      }
      catch(exception &e)
      {
      cout << e.what();
      }

      Member 8534035 wrote:

      ...and all the member functions of the using class are static functions!

      So have you tried using it in a class with non-static functions?

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

      1 Reply Last reply
      0
      • M Member 8534035

        I need a sorted list of strings with some additional information for each entry, so I thought about to use std::map I am doing just simple things: Definition:

        typedef std::map tTABMNEMO;
        tTABMNEMO TabMnemo;

        and in constructor of using class I am calling firstly:

        TabMnemo.clear();

        already this first access (in constructor of using class) causes an access violation. any idea, what could be wrong? Do I need to initialize anyhow? maybe it is because of my program structure? this map is defined globally outside of the class and all the member functions of the using class are static functions!

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        In my opinion that shouldn't happen. Are you sure the access violation is triggered by the clear method invocation? Could you opst the exact code?

        In testa che avete, signor di Ceprano?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups