|
![](/i/fill.gif) |
John VanSickle <evi### [at] kosher hotmail com> 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];
}
};
//-------------------------------------------------------------
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |