0

im curently working on my project to school. Im writing a text-based adventure game in c while using codeblocks. I started as console application, that went fairly well and i was satisfied. But the project must contain a GUI made in WxWidgets, so i just wanted to add a GUI to my console app, here the problems starts. Im curently fighting with private and public objects in WxWidgets and im still getting this one error C:\Users\Petr2\Desktop\Programko\TextovkaWxW\inventar.cpp|12|undefined reference to WxWFrame::TextCtrl1'| this error. I tried to define all my functions into public section WxWidgets.

 public:

    WxWFrame(wxWindow* parent,wxWindowID id = -1);
    virtual ~WxWFrame();
    wxString vstup;
    static wxString vystup;
    static int getInput();
    static char input[100];
    static int parseAndExecute();
    static void moveObject(const char *noun, OBJECT *from, OBJECT *to);
    static void executeLook(const char *noun);
    static void executeGo(const char *noun);
    static void executeGet(const char *noun);
    static void executeDrop(const char *noun);
    static void executeGive(const char *noun);
    static void executeAsk(const char *noun);
    static void executeInventory(void);
    static int nounIsInTags(const char *noun, const char **tags);
    static int listObjectsAtLocation(OBJECT *location);

Here is the function, where im getting the error, its in another .cpp file

void WxWFrame::moveObject(const char *noun, OBJECT *from, OBJECT *to)
{
   OBJECT *obj = parseObject(noun);
   if (obj == NULL)
   {
      TextCtrl1->AppendText("I don't understand what item you mean.\n");
   }

And i just dont really know, how am i supposed to define my own variable "vystup" or use the TextCtrl1-> AppendText()

I will appreciate every answer and i will add whatever you want from my code or answer any quiestion. I just...dont know, i tried to look for posible answers but nothing that really helped me. So thats why im writing here. Thank you

PS: Im sorry for my bad english

Liut
  • 1
  • 1
  • I don't see where `TextCtrl1` is declared at all let alone defined. Plus why are all those member functions of your class `static`? – Captain Obvlious May 08 '16 at 19:11
  • `TextCtrl1` is declared in privat section of WxWMain.h right here `//(*Declarations(WxWFrame) wxStatusBar* StatusBar1; wxTextCtrl* TextCtrl2; static wxTextCtrl* TextCtrl1; //*) ` They are static, because, it was yelling error at me, that `C:\Users\Petr2\Desktop\Programko\TextovkaWxW\WxWMain.h|78|error: invalid use of member 'WxWFrame::TextCtrl1' in static member function|` – Liut May 08 '16 at 19:16
  • That's a terrible reason to make them static. Very very terrible. – Captain Obvlious May 08 '16 at 19:22
  • Good to know, that is very terrible reason to do that. So im just trying to learn, why to not do that, or why it is so bad solution, im just programing virgin who has c++ for first semester. – Liut May 08 '16 at 19:27
  • If you're just learning then I strongly suggest you do not do it using wxWindows or any other GUI framework. It introduces another major thing to learn and shifts your focus from learning the language to learning the framework. Stick with command line / console applications until you have a much firmer grasp of the language. – Captain Obvlious May 08 '16 at 19:35
  • I would love to, the console app worked so well for me, until i add the wxwidgets GUI... Unlucky, i have to add it to my school project, or i will not pass the class, thats why im trying to find the solution and also thank you for the link to that post with undefined references, trying to find the answer here. – Liut May 08 '16 at 19:39
  • Im maybe stupid, or tired, that i cant find the way, even with your link, to define properly my variable... – Liut May 08 '16 at 20:30
  • The very last part of this linked answer - http://stackoverflow.com/a/12574407/845568. You really should speak to your teacher or their assistant if you're having this much trouble. You're trying to fix a solution that's wrong in the first place so even if you take care of the issue the end result is still borked and you're in for an even rougher time. – Captain Obvlious May 08 '16 at 20:33
  • Yea, i will do that, thanks for all that time and help, appreciated. – Liut May 08 '16 at 20:41
  • @Liut, it is also very weird to expect student learning C++ to create a GUI using one of the C++ framework. What college/university is this? The GUI creation should be an advanced topic. – Igor May 09 '16 at 20:48
  • @Igor , im studying first year of electrotechnical faculty of VUT in Brno...in second semester, we got mandatory class with c and c++ programing, in the first half of the semester, we used just console apps and in the other half, we jumped into this c++ framework, to create some basic GUIs etc. – Liut May 09 '16 at 21:08
  • @Liut, like I said:this is an advanced topic that should not be in the curriculum of the first year. You don't even know the language and the basic design principle - so how do they expect you to design the GUI stuff properly. The GUI has to be an advanced topic for the C++/any language there is. – Igor May 09 '16 at 23:03
  • @Igor i know, they probably expect some experience with the languagee from hight school, but i have none, i had big pproblem during the semester and i have problems to pass the class, this...project, is the final thing of the class. I know its advanced, but i need to do it, somehow, because the class is mandatory – Liut May 10 '16 at 08:43

0 Answers0