OT: c++ q

OT: c++ q

Shachar Shemesh shachar at shemesh.biz
Sun Apr 26 17:31:59 IDT 2009


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20090426/bed0469c/attachment.html>


More information about the Linux-il mailing list