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. C / C++ / MFC
  3. CList with user defined type is not working

CList with user defined type is not working

Scheduled Pinned Locked Moved C / C++ / MFC
4 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    within my class i created a struct and a CList template containing the struct. but i something goes wrong when i try to add a struct variable to the CList object. Whats wrong? #include "StdAfx.h" #include "Afxtempl.h" //HoleVok.h class CHoleVok { private: typedef struct TABELLE { CString strSQL; CString intTID; int intVokAnzahl; CList clistGeprueft; }; CArray arrTabellen; CDatabase *db; public: bool fnConnect(CDaoDatabase &db); }; ___________________________________________ #include "stdafx.h" #include "HoleVok.h" //HoleVok.cpp bool CHoleVok::fnConnect(CDaoDatabase &db) { TABELLE tabTest1; tabTest1.clistGeprueft.AddTail(20); tabTest1.clistGeprueft.AddTail(21); tabTest1.intTID = 4; tabTest1.intVokAnzahl = 200; tabTest1.strSQL = "Das Wetter ist schoen"; arrTabellen.Add(tabTest1); return true; }

    U 1 Reply Last reply
    0
    • L Lost User

      within my class i created a struct and a CList template containing the struct. but i something goes wrong when i try to add a struct variable to the CList object. Whats wrong? #include "StdAfx.h" #include "Afxtempl.h" //HoleVok.h class CHoleVok { private: typedef struct TABELLE { CString strSQL; CString intTID; int intVokAnzahl; CList clistGeprueft; }; CArray arrTabellen; CDatabase *db; public: bool fnConnect(CDaoDatabase &db); }; ___________________________________________ #include "stdafx.h" #include "HoleVok.h" //HoleVok.cpp bool CHoleVok::fnConnect(CDaoDatabase &db) { TABELLE tabTest1; tabTest1.clistGeprueft.AddTail(20); tabTest1.clistGeprueft.AddTail(21); tabTest1.intTID = 4; tabTest1.intVokAnzahl = 200; tabTest1.strSQL = "Das Wetter ist schoen"; arrTabellen.Add(tabTest1); return true; }

      U Offline
      U Offline
      User 10281465
      wrote on last edited by
      #2

      The CList is a template. You need to define what is being stored in its definition. such as. typedef struct TABELLE { CString strSQL; CString intTID; int intVokAnzahl; CList clistGeprueft; }; After this the following works fine. TABELLE NewTab; NewTab.clistGeprueft.AddTail(20); NewTab.clistGeprueft.AddTail(21); NewTab.clistGeprueft.AddTail(24); int myval; myval = NewTab.clistGeprueft.GetHead(); POSITION pos = NewTab.clistGeprueft.GetHeadPosition(); myval = NewTab.clistGeprueft.GetNext(pos); myval = NewTab.clistGeprueft.GetNext(pos); myval = NewTab.clistGeprueft.GetNext(pos); myval = NewTab.clistGeprueft.GetNext(pos); NOTE the last line here fails because the list had 3 elements and I did not test for a NULL position. ================== The original message was: within my class i created a struct and a CList template containing the struct. but i something goes wrong when i try to add a struct variable to the CList object. Whats wrong?

      #include "StdAfx.h"
      #include "Afxtempl.h"

      //HoleVok.h

      class CHoleVok
      {
      private:

      typedef struct TABELLE
      {
      CString strSQL;
      CString intTID;
      int intVokAnzahl;
      CList clistGeprueft;
      };

      CArray arrTabellen;

      CDatabase *db;

      public:
      bool fnConnect(CDaoDatabase &db);

      };
      ___________________________________________
      #include "stdafx.h"
      #include "HoleVok.h"

      //HoleVok.cpp

      bool CHoleVok::fnConnect(CDaoDatabase &db)
      {
      TABELLE tabTest1;
      tabTest1.clistGeprueft.AddTail(20);
      tabTest1.clistGeprueft.AddTail(21);
      tabTest1.intTID = 4;
      tabTest1.intVokAnzahl = 200;
      tabTest1.strSQL = "Das Wetter ist schoen";

      arrTabellen.Add(tabTest1);

      return true;
      }

      U 1 Reply Last reply
      0
      • U User 10281465

        The CList is a template. You need to define what is being stored in its definition. such as. typedef struct TABELLE { CString strSQL; CString intTID; int intVokAnzahl; CList clistGeprueft; }; After this the following works fine. TABELLE NewTab; NewTab.clistGeprueft.AddTail(20); NewTab.clistGeprueft.AddTail(21); NewTab.clistGeprueft.AddTail(24); int myval; myval = NewTab.clistGeprueft.GetHead(); POSITION pos = NewTab.clistGeprueft.GetHeadPosition(); myval = NewTab.clistGeprueft.GetNext(pos); myval = NewTab.clistGeprueft.GetNext(pos); myval = NewTab.clistGeprueft.GetNext(pos); myval = NewTab.clistGeprueft.GetNext(pos); NOTE the last line here fails because the list had 3 elements and I did not test for a NULL position. ================== The original message was: within my class i created a struct and a CList template containing the struct. but i something goes wrong when i try to add a struct variable to the CList object. Whats wrong?

        #include "StdAfx.h"
        #include "Afxtempl.h"

        //HoleVok.h

        class CHoleVok
        {
        private:

        typedef struct TABELLE
        {
        CString strSQL;
        CString intTID;
        int intVokAnzahl;
        CList clistGeprueft;
        };

        CArray arrTabellen;

        CDatabase *db;

        public:
        bool fnConnect(CDaoDatabase &db);

        };
        ___________________________________________
        #include "stdafx.h"
        #include "HoleVok.h"

        //HoleVok.cpp

        bool CHoleVok::fnConnect(CDaoDatabase &db)
        {
        TABELLE tabTest1;
        tabTest1.clistGeprueft.AddTail(20);
        tabTest1.clistGeprueft.AddTail(21);
        tabTest1.intTID = 4;
        tabTest1.intVokAnzahl = 200;
        tabTest1.strSQL = "Das Wetter ist schoen";

        arrTabellen.Add(tabTest1);

        return true;
        }

        U Offline
        U Offline
        User 10281465
        wrote on last edited by
        #3

        Benedikt, I missed what the lt gt signs did to the code. Now my sample worked. Can you describe what goes wrong? Given the code is not being post clearly is the problem with the CList or the CArray? The following is adding the "pre" html prior to the code just to see what it looks like.

        typedef struct TABELLE
        {
        CString strSQL;
        CString intTID;
        int VokAnzahl;
        CList clistGeprueft;
        };

        L 1 Reply Last reply
        0
        • U User 10281465

          Benedikt, I missed what the lt gt signs did to the code. Now my sample worked. Can you describe what goes wrong? Given the code is not being post clearly is the problem with the CList or the CArray? The following is adding the "pre" html prior to the code just to see what it looks like.

          typedef struct TABELLE
          {
          CString strSQL;
          CString intTID;
          int VokAnzahl;
          CList clistGeprueft;
          };

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I think I've found the problem. CList doesn't provide a copy or an assignement operater witch is needed. So it is not possible to store a clist or a carray within a clist or a carray. But this is what i need!

          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