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. Managed C++/CLI
  4. metodes in template class arn't recognize

metodes in template class arn't recognize

Scheduled Pinned Locked Moved Managed C++/CLI
helpc++question
3 Posts 2 Posters 1 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.
  • C Offline
    C Offline
    chen_k
    wrote on last edited by
    #1

    I have in my project a template class. When I try to use a method in that class, then i get error messages like that: C:\My Documents\tel_op3\tel_op3\info_dlg.cpp(14) : error C2228: left of '.setFilename' must have class/struct/union type What could be the problem? Thanks, Chen

    C 1 Reply Last reply
    0
    • C chen_k

      I have in my project a template class. When I try to use a method in that class, then i get error messages like that: C:\My Documents\tel_op3\tel_op3\info_dlg.cpp(14) : error C2228: left of '.setFilename' must have class/struct/union type What could be the problem? Thanks, Chen

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Include the header file of the class in the cpp file. If this doesn't work, give more details because it is impossible to know what's happening with so little clues.

      C 1 Reply Last reply
      0
      • C Cedric Moonen

        Include the header file of the class in the cpp file. If this doesn't work, give more details because it is impossible to know what's happening with so little clues.

        C Offline
        C Offline
        chen_k
        wrote on last edited by
        #3

        I included the header file of the template class in the header of the class that use it, adding it to the cpp file doesn't help (i get the same error messages). Details: I wrote a template class that represent a list of objects. this it's definition: template< class T > class obj_list { public: obj_list(); virtual ~obj_list(); void addObject(T *object); T getObjectAt(int i); void saveObjects(); int getNumOfObjects(); void close_file(); void setFilename(char *fileName); private: char* file_name; CObList objects; POSITION pos; CFile objects_file; int numOfObjects; }; It's implication came in the same header file (i heard that when i writing a template class I need to put the definition and implication in the header file). I have a class named info_dlg, and in it's header file I create a variable of the type of obj_list, by writing this line: obj_list user_s(); (user_info is a class that hold information about a user). In the cpp of info_dlg, I have some methods that in them I try to use some of obj_list's methods, but i get error messages like that: C:\My Documents\tel_op3\tel_op3\info_dlg.cpp(14) : error C2228: left of '.setFilename' must have class/struct/union type C:\My Documents\tel_op3\tel_op3\info_dlg.cpp(21) : error C2228: left of '.saveObjects' must have class/struct/union type C:\My Documents\tel_op3\tel_op3\info_dlg.cpp(41) : error C2228: left of '.addObject' must have class/struct/union type I hope this is enough details, and you could help me. Chen

        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