POV-Ray : Newsgroups : povray.off-topic : Job Interview : Re: Job Interview Server Time
29 Jul 2024 12:19:17 EDT (-0400)
  Re: Job Interview  
From: nemesis
Date: 5 Mar 2012 14:13:25
Message: <4f551055$1@news.povray.org>
Warp escreveu:
> John VanSickle <evi### [at] kosherhotmailcom> wrote:
>> Evidently not.  In chatting with the interviewers that day, they all 
>> confirmed that most bugs are stupid things like this.
> 
>   Sadly, the vast majority of people programming in C (or C++) professionally
> out there don't actually know the language enough to avoid such trivial ways
> to shoot yourself in the foot. It may be something that you and me can spot
> in a second, but I'm certain the average professional C programmer can't see
> it. It's no wonder programs are so buggy. A sad state of affairs.
> 
>   In C++ in particular this is another situation were the majority of C++
> programmers out there have no idea what's wrong:
> 
> //-------------------------------------------------------------
> template<typename Value_t>
> class Array
> {
>     Value_t* mData;
>     std::size_t mSize;
> 
>  public:
>     Array(std::size_t size):
>         mData(new Value_t[size]),
>         mSize(size)
>     {}
> 
>     ~Array() { delete[] mData; }
> 
>     Value_t& operator[](std::size_t index)
>     {
>         assert(index < mSize);
>         return mData[index];
>     }
> 
>     const Value_t& operator[](std::size_t index) const
>     {
>         assert(index < mSize);
>         return mData[index];
>     }
> };

the C issues were self-evident, but this is not much easier than trying 
to read some idiomatic haskell... :P

BTW, why

      Array(std::size_t size):
          mData(new Value_t[size]),
          mSize(size)
      {}

rather than

      Array(std::size_t size)
      {
          mData=new Value_t[size];
          mSize=size;
      }

when you've got exactly 2 extra chars (:,) in the first case?  Don't 
tell me it's because some compile-time initialization that is not done 
in the second case...

is also delete[] defined when you define those operator[] methods?

C++ is so alien...

-- 
a game sig: http://tinyurl.com/d3rxz9


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.