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. CTreeObject class

CTreeObject class

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresperformancequestion
3 Posts 2 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.
  • _ Offline
    _ Offline
    _Flaviu
    wrote on last edited by
    #1

    Hi all of you. I have to develop a project, where I need to use a CTree object, something very similar to CTreeCtrl. But this object, will contain only 2 things on every items: int and CString (just like CTreeCtrl does). I avoid to use CTreeCtrl, because this object will not be an visible object, just hold data as a tree structure. Could you advice me what should I use in this case ? I mean, in this object I need to store something like this: 4 root --- 5 child1 --------6 child11 --------7 child12 --------8 child13 --- 9 child2 --- 10 child3 --------12 child31 --------13 child32 --------14 child33 --- 11 child4 Any advice will be welcome, but I have to keep this object simple, as being possible ... Yes, I could use a CTreeCtrl, but this object will had an ID, will be derived from CWnd, etc. ... and my data must keep it only in memory, not inside of CWnd control ... Kindly thank you.

    _ 1 Reply Last reply
    0
    • _ _Flaviu

      Hi all of you. I have to develop a project, where I need to use a CTree object, something very similar to CTreeCtrl. But this object, will contain only 2 things on every items: int and CString (just like CTreeCtrl does). I avoid to use CTreeCtrl, because this object will not be an visible object, just hold data as a tree structure. Could you advice me what should I use in this case ? I mean, in this object I need to store something like this: 4 root --- 5 child1 --------6 child11 --------7 child12 --------8 child13 --- 9 child2 --- 10 child3 --------12 child31 --------13 child32 --------14 child33 --- 11 child4 Any advice will be welcome, but I have to keep this object simple, as being possible ... Yes, I could use a CTreeCtrl, but this object will had an ID, will be derived from CWnd, etc. ... and my data must keep it only in memory, not inside of CWnd control ... Kindly thank you.

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      You could use a structure as below -

      struct TreeNode
      {
      int i;
      CString str;
      std::vector children;
      };

      Create one instance of TreeNode that would be the root. The root can then have children who can have children etc. You could use std::string or std::wstring instead of CString. You can use the push_back or emplace_back methods to add children.

      «_Superman_»  _I love work. It gives me something to do between weekends.

      _Microsoft MVP (Visual C++) (October 2009 - September 2013)

      Polymorphism in C

      _ 1 Reply Last reply
      0
      • _ _Superman_

        You could use a structure as below -

        struct TreeNode
        {
        int i;
        CString str;
        std::vector children;
        };

        Create one instance of TreeNode that would be the root. The root can then have children who can have children etc. You could use std::string or std::wstring instead of CString. You can use the push_back or emplace_back methods to add children.

        «_Superman_»  _I love work. It gives me something to do between weekends.

        _Microsoft MVP (Visual C++) (October 2009 - September 2013)

        Polymorphism in C

        _ Offline
        _ Offline
        _Flaviu
        wrote on last edited by
        #3

        Thank you, I have solved the problem after your idea.

        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