944,068 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1199
  • C++ RSS
Oct 30th, 2009
0

"request for member of non class type" error

Expand Post »
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
Quote ...
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
C++ Syntax (Toggle Plain Text)
  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
C++ Syntax (Toggle Plain Text)
  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
C++ Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
leowdeo is offline Offline
2 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Calculator in a dialog box
Next Thread in C++ Forum Timeline: SIGSEV in array declaration inside a switch





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC