Re: OT: c++ q
Erez D wrote: hi i have encountered a problem with g++ i have a class a, with forward declaration of a function do_something and a constructor a(int val); i implement them in a cpp file. g++ complains of redefinition of the constructor but not of the do_something() function. why ? files: == a.h === class a { int m_a; a (int val); void do_somthing() } == a.cpp === #include a.h a::do_somthing {a.m_a++;}; a::a(int val):m_a(val) {}; any idea ? Send an actual couple of files. What you sent is impossible to debug (I doubt g++ does not complain that do_somthing is defined with no return type and no parenthesis). Shachar -- Shachar Shemesh Lingnu Open Source Consulting Ltd. http://www.lingnu.com ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: OT: c++ q
On Sun, Apr 26, 2009 at 3:43 PM, Shachar Shemesh shac...@shemesh.bizwrote: Erez D wrote: hi i have encountered a problem with g++ i have a class a, with forward declaration of a function do_something and a constructor a(int val); i implement them in a cpp file. g++ complains of redefinition of the constructor but not of the do_something() function. why ? files: == a.h === class a { int m_a; a (int val); void do_somthing() } == a.cpp === #include a.h a::do_somthing {a.m_a++;}; a::a(int val):m_a(val) {}; any idea ? Send an actual couple of files. What you sent is impossible to debug (I doubt g++ does not complain that do_somthing is defined with no return type and no parenthesis). Shachar you are right. i just wanted to give a small example instead of send my whole project to be inspected. however after fixing the syntax of this small example, i can't seem to duplicate the problem that happened in the project. so thanks anyway. erez. -- Shachar Shemesh Lingnu Open Source Consulting Ltd.http://www.lingnu.com ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: OT: c++ q
Erez D wrote: you are right. i just wanted to give a small example instead of send my whole project to be inspected. Which I doubt anyone would. however after fixing the syntax of this small example, i can't seem to duplicate the problem that happened in the project. A clear symptom that the problem is not what you think it is. Try using -E on gcc - it tells it to run the C preprocessor and stop. Inspect the resulting file - it may reveal the problem. Shachar -- Shachar Shemesh Lingnu Open Source Consulting Ltd. http://www.lingnu.com ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: OT: c++ q
On Sun, Apr 26, 2009 at 4:07 PM, Shachar Shemesh shac...@shemesh.bizwrote: Erez D wrote: you are right. i just wanted to give a small example instead of send my whole project to be inspected. Which I doubt anyone would. i would not send my whole project as this is spamming (and other reasons too) however after fixing the syntax of this small example, i can't seem to duplicate the problem that happened in the project. A clear symptom that the problem is not what you think it is. Try using -E on gcc - it tells it to run the C preprocessor and stop. Inspect the resulting file - it may reveal the problem. I should be so lucky ... as i have no #defines whatsoever, the preprocessor output was exactly what i expected. i found some voodoo though: g++ -E -I . -c source/myclass.cpp x.cpp g++ -c x.cpp works fine, however: g++ -I . -c source/myclass.cpp returns a redefinition of ... error Shachar -- Shachar Shemesh Lingnu Open Source Consulting Ltd.http://www.lingnu.com ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: OT: c++ q
On Sun, Apr 26, 2009 at 5:04 PM, Erez D erez0...@gmail.com wrote: On Sun, Apr 26, 2009 at 4:07 PM, Shachar Shemesh shac...@shemesh.bizwrote: Erez D wrote: you are right. i just wanted to give a small example instead of send my whole project to be inspected. Which I doubt anyone would. i would not send my whole project as this is spamming (and other reasons too) however after fixing the syntax of this small example, i can't seem to duplicate the problem that happened in the project. A clear symptom that the problem is not what you think it is. Try using -E on gcc - it tells it to run the C preprocessor and stop. Inspect the resulting file - it may reveal the problem. I should be so lucky ... as i have no #defines whatsoever, the preprocessor output was exactly what i expected. i found some voodoo though: g++ -E -I . -c source/myclass.cpp x.cpp g++ -c x.cpp works fine, however: g++ -I . -c source/myclass.cpp returns a redefinition of ... error the funny is that it does compile on my other computer without any problems so : i get an error on jaunty - gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) it compiles cleanly on intrepid - gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12) Shachar -- Shachar Shemesh Lingnu Open Source Consulting Ltd.http://www.lingnu.com ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: OT: c++ q
On Sunday 26 April 2009 15:38:53 Erez D wrote: files: == a.h === MISSING: #ifndef __FILE_H__ class a { int m_a; a (int val); void do_somthing() } MISSING: semicolon, last line should be }; MISSING: #endif // __FILE_H__ == a.cpp === #include a.h a::do_somthing {a.m_a++;}; a::a(int val):m_a(val) {}; GRADE: C- ~ 70. Go back to school, and as punishment re-implement quick_sort in VB.NET. ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: OT: c++ q
diego, you didn't find all the errors, try again ;-) On Sun, Apr 26, 2009 at 5:19 PM, Diego Iastrubni elc...@kde.org wrote: On Sunday 26 April 2009 15:38:53 Erez D wrote: files: == a.h === MISSING: #ifndef __FILE_H__ class a { int m_a; a (int val); void do_somthing() } MISSING: semicolon, last line should be }; MISSING: #endif // __FILE_H__ == a.cpp === #include a.h a::do_somthing {a.m_a++;}; a::a(int val):m_a(val) {}; GRADE: C- ~ 70. Go back to school, and as punishment re-implement quick_sort in VB.NET. ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: OT: c++ q
Diego Iastrubni wrote: On Sunday 26 April 2009 15:38:53 Erez D wrote: files: == a.h === MISSING: #ifndef __FILE_H__ There is no syntactical requirement to place those. If you do place those, it is customary to call them after the file's name. Also, __ is only prepended to system includes, so it should have been: #ifndef A_H Also, you forgot to add: #define A_H which is, after all, the reason we go through the trouble of putting the #ifndef to begin with. class a { int m_a; a (int val); void do_somthing() } MISSING: semicolon, last line should be }; MISSING: #endif // __FILE_H__ == a.cpp === #include a.h a::do_somthing {a.m_a++;}; a::a(int val):m_a(val) {}; Missed lots and lots and lots of errors in this file. GRADE: C- ~ 70. Go back to school, and as punishment re-implement quick_sort in VB.NET. Now that's going the cruel and unusual route. I do think every programmer should take the time to implement binary search and quick sort at least once from scratch. The number of corner cases there is outstanding, and it is a great practice of thinking of the fine details. Shachar -- Shachar Shemesh Lingnu Open Source Consulting Ltd. http://www.lingnu.com ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: OT: c++ q
On Sunday 26 April 2009 17:31:59 Shachar Shemesh wrote: Go back to school, and as punishment re-implement quick_sort in VB.NET. Now that's going the cruel and unusual route. I do think every programmer should take the time to implement binary search and quick sort at least once from scratch. The number of corner cases there is outstanding, and it is a great practice of thinking of the fine details. Beeing a little serious: I am not sure quick_sort is a must, as quite frankly it's a reall mess and I don't understand it. But heap sort and binary sort, yes. Those are a must. /me will need to back to the books and remember how heap sort works ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: OT: c++ q
Diego Iastrubni wrote: On Sunday 26 April 2009 17:31:59 Shachar Shemesh wrote: Go back to school, and as punishment re-implement quick_sort in VB.NET. Now that's going the cruel and unusual route. I do think every programmer should take the time to implement binary search and quick sort at least once from scratch. The number of corner cases there is outstanding, and it is a great practice of thinking of the fine details. Beeing a little serious: I am not sure quick_sort is a must, as quite frankly it's a reall mess and I don't understand it. Sounds like an excellent reason to go there. But heap sort and binary sort, yes. Those are a must. Heap sort is fairly straight forward once you have the heap. I do believe every programmer should know how to write a heap (preferably, a compressed one, where you keep no node pointers). Shachar -- Shachar Shemesh Lingnu Open Source Consulting Ltd. http://www.lingnu.com ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il