By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,131 Members | 1,830 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,131 IT Pros & Developers. It's quick & easy.

bug patten in C++

P: n/a
Hi,

I am still learing C++. What are the most common mistakes that people
often made in C++? Mistach of new/delete should be one. How about
others?

Andy

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
using = instead of ==
passing a value when they should be passing an address
not implementing deep copy in copy ctors and operator=
not checking whether 'this == &rhs' in operator=
/ david

Jul 23 '05 #2

P: n/a
"Andy" <gn***@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,

I am still learing C++. What are the most common mistakes that people
often made in C++? Mistach of new/delete should be one. How about
others?


Spelling and grammar. Work on them. Seriously.
They're far more important when dealing with
computer languages than with human languages.

Another big mistake I see often with beginners is
trying to write code too soon (not having read
enough) and writing too much code all at once.
I.e. trying to run before learning to walk.

Another one I've seen too many times is being too
cheap to purchase quality textbooks (or too lazy
to find a library from which to borrow them), and
trying to rely solely on the internet for information;
this very often results in acceptance of incorrect
information as correct, and much wasted time
and effort.

BTW have you read the C++ FAQ? If not, do so. Do it
now. Go directly to the FAQ, do not pass GO, do
not collect $200. http://www.parashift.com/c++-faq-lite/
There will be a quiz on Monday (just kidding :-) )

-Mike
Jul 23 '05 #3

P: n/a
In message <11**********************@f14g2000cwb.googlegroups .com>, Andy
<gn***@yahoo.com> writes
Hi,

I am still learing C++. What are the most common mistakes that people
often made in C++? Mistach of new/delete should be one. How about
others?

Confusion between new[]/new, delete[]/delete.

*Using* new[]/delete[] at all ;-) In most cases std::vector is what's
really needed.

Using delete, instead of letting a smart pointer take care of it.

Unnecessary use of new (particularly prevalent in ex-Java programmers)

For the rest, just look how many postings here are answered with a
reference to the FAQ.

--
Richard Herring
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.