"request for member of non class type" error

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2008
Posts: 2
Reputation: leowdeo is an unknown quantity at this point 
Solved Threads: 0
leowdeo leowdeo is offline Offline
Newbie Poster

"request for member of non class type" error

 
0
  #1
Oct 30th, 2009
i am trying to create a simple class to simply create an imagelist which i will later on use in a toolbar class. The problem is that the empty Add() member function has an error
error: request for member `Add' in `myImageList', which is of non-class type `CImageList ()()'
i have searched around the forum and i got similar errors but i believe that their problems were different.

//this is the class declaration in file CImageList.h
  1. #include<commctrl.h>
  2.  
  3. class CImageList
  4. {
  5. public:
  6. CImageList();
  7. ~CImageList();
  8.  
  9. void Add();
  10. private:
  11. HIMAGELIST m_hImageList;
  12. };

//and this is the definition
  1. #include<windows.h>
  2. #include<commctrl.h>
  3. #include "CImageList.h"
  4.  
  5. CImageList::CImageList()
  6. {
  7. m_hImageList=ImageList_Create(32, 32, ILC_COLOR32, 0, 15);//returns NULL if the fuction fails
  8.  
  9. if(!m_hImageList) MessageBox(NULL,"failed to create m_hImageList","CImageList constructor error",MB_ICONERROR);
  10. else MessageBox(NULL,"m_hImageList created sucessfully :)","CImageList constructor ",MB_OK);
  11. }
  12.  
  13. CImageList::~CImageList()
  14. {
  15. }
  16.  
  17. void CImageList::Add()
  18. {
  19. //currently empty but for adding icons to imagelist
  20. }

//then in main.cpp I added these
  1. #include "CImageList.h"
  2. CImageList myImageList;
  3. ...
  4. ...
  5. LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  6. {
  7. switch (message) /* handle the messages */
  8. {
  9. case WM_CREATE:
  10. myImageList.Add();//HERE IS THE ERROR
  11. break;
  12. ....
  13. ....
  14. }
  15. }

Here is part of the compile log... iam using devcpp version 4.9.9.2
[ICODE]

main.cpp: In function `LRESULT WindowProcedure(HWND__*, UINT, WPARAM, LPARAM)':
main.cpp:80: error: request for member `Add' in `myImageList', which is of non-class type `CImageList ()()'

make.exe: *** [main.o] Error 1

Execution terminated
[ICODE]

ps: sorry for the long code but i have no clue what this error means.
Thanks in advance
from Dr deo
Reply With Quote Quick reply to this message  
Reply

Message:



Other Threads in the C++ Forum


Views: 272 | Replies: 0
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC