0

Friends,
when i try to compile this program i am geting this error!!
ListMemoryFree.cpp: In member function 'void example::add(LinkSlcMap*)':
ListMemoryFree.cpp:41: error: 'm_link' was not declared in this scope

but to me it seems fine.:) plz point out my mistake!!

#include <iostream>
#include <list>
using namespace std;

struct LinkSlcMap
{
    std::string mLinkName;
    std::string mProfileName;
    uint8_t slc;
    bool linkInfo;

    ~LinkSlcMap()
    {
      printf("structure destructure called\n");
    }
};

class example
{
public:
    example(){}
    ~example();
    void add(LinkSlcMap * link);
private:
    list <LinkSlcMap *> m_Link;
};

example::~example()
    {
      printf("Class Destructure called\n");
      LinkSlcMap *link;
      list <LinkSlcMap *>::iterator it;
      for(it=m_Link.begin();it!=m_Link.end();it++)
      {
        link = *it;
        delete link;
      }
void example::add(LinkSlcMap * link)
{
     m_link.push_back(link);
}

int main()
{
    example *ex = new example;
    LinkSlcMap *link;
    for(int i=0; i<5; i++)
    {
      link = new LinkSlcMap;
      link->slc = i;
      ex->add(link);
    }
    delete ex;

    return 0;
}
2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by johnray31
0

Oh!!!
What the crap i am doing!! yes that is a very silly mistake.

Anyway thanks!! :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.