![]() |
|
#1
|
|||
|
|||
Simple program with many errorsHi,
I am trying to prepare simple project for lab exercises (YES, we are trying to use fltk 1.1.9 in a course about C++ programming). Well, I am new to this and I have problems with basic concepts. Here is a "should be simple" program which has some really bad erros, it doesn't even compile. And I am unable to prepare a correct version, Any suggestion will be of great help. BTW: I have posted the same question also to fltk.org forum, please tell me, if you (GIDForums) do not like such flooding. CPP / C++ / C Code:
Last edited by LuciWiz : 16-May-2009 at 13:23.
Reason: Please insert your C++ code between [cpp] & [/cpp] tags
|
|||
|
#2
|
|||
|
|||
Re: Simple program with many errorsHi again,
I found all (?) mistakes and improved the program. It ended with 110 line and was already served as a demonstration example. Quite successful! The first error was in the foolowing line: Background(Fl_JPEG_Image bgimg) : Fl_Box(0,0,800,530) { There is no copy constructor for Fl_JPEG_Image, thus a reference should be used. This was compiler error. The second error was in the line (and similar a few lines down): Fl_Button buttonPlus(100,0,50,50,"+"); Created buttonPlus is a local variable for Toolbar::Toolbar(), thus I get runtime error becuase it does not exist after the constructor finishes. I am sending here the final code (well, I used a picture called slovenia.jpg, it can be any JPEG, just change the name in the code). Any comments or suggestions? Best regards, Robert CPP / C++ / C Code:
|
|
#3
|
|||
|
|||
Re: Simple program with many errorsHey how do you compile it?
I tried to compile like this: gcc -lfltk test2.cxx -o test2 but it's saying: /tmp/cctxceop.o: In function `main': test2.cxx:(.text+0x537): undefined reference to `Fl_JPEG_Image::Fl_JPEG_Image(char const*)' collect2: ld returned 1 exit status Can you give me the complete compile command? |
|
#4
|
|||
|
|||
Re: Simple program with many errorsI tried to put the callback inside the class Main_window...but could not succeed...it's throwing a lot of errors.....can you tell me how to do that....it would be very much like java...
|
|
#5
|
|||
|
|||
Re: Simple program with many errorsHi,
Compiler parameters depend on system and instalation method. For example: 1. On Linux you can use fltk-config which is a nice script: fltk-config --use-images --compile test.cxx 2. On Linux/Ubuntu 9.04 + FLTK from repository the following line is working for me: g++ -Wall test.cxx -lfltk -lfltk_images 3. On Linux/Ubuntu old + FLTK compiled from sources I am using: g++ -Wall test.cxx -lfltk -lfltk_images -lfltk_jpeg -lXext 4. To compile on Windows + VC++ you must follow some instructions, e.g. from a book "Bjarne Stroustrup: Programming -- Principles and Practice Using C++". Quote:
Callback functions cannot be a class member. There will be a problem with types. An explanation for this is given here (but it is not an easy explanation): http://www.parashift.com/c++-faq-lite/pointers-to-members.html (Why I cannot post the complete link?? Search for "Pointers to member functions") I like Java, too. But do not try to use to much Java style in C++ programs. Going into details, C++ is a very different language! Robert |
|
#6
|
|||
|
|||
Re: Simple program with many errorsThanks a lot for ur help...it compiled and ran perfectly....also ur explanation on not having callbacks as class members is quite satisfactory...
|
|
#7
|
|||
|
|||
Re: Simple program with many errorsHey I succeeded in putting the callbacks inside the class......
Here's the code....... CPP / C++ / C Code:
|
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Equation solver | RazoR | C Programming Language | 3 | 18-May-2008 10:24 |
| Please help me to convert a simple C++ program into an object-oriented one. | zekesteer | C++ Forum | 5 | 05-Jan-2008 11:05 |
| Two-Tier data dissemination code installation problem | nidhibansal1984 | Computer Software Forum - Linux | 6 | 16-Sep-2007 11:13 |
| i need help with a simple program!! | alfie27 | C++ Forum | 1 | 06-Oct-2006 22:29 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The