分级目录实现

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

class Classify
{
public:
 Classify GetFirstChild()
 {
  return *(*m_NextClass.begin());
 }

 void Insert(Classify* item)
 {
  m_NextClass.push_back(item);
 }

 static Classify* GetNewOne()
 {
  Classify* p = new Classify;
  return p;
 }

// private:
 string m_strName;
 int m_Index;
 list<Classify*> m_NextClass;
};

int main(int _Argc, char** argv)
{
 Classify test;
 test.m_Index = 1;
 test.m_strName = "Father";
 Classify* child = Classify::GetNewOne();
 child->m_Index = 21;
 child->m_strName = "child1";
 test.Insert(child);

 Classify* child2 = Classify::GetNewOne();
 child2->m_Index = 22;
 child2->m_strName = "child2";
 test.Insert(child2);

 Classify* pChildChild = Classify::GetNewOne();
 pChildChild->m_Index = 31;
 pChildChild->m_strName = "childChild1";
 child->Insert(pChildChild);
 return 0;
}

你可能感兴趣的:(String,insert,include)