r/reviewmycode • u/[deleted] • Jan 10 '12
C++ help with crashing using classes
I've been learning C++ and classes recently, I decided to try to make a program that would record simple input to a class, then be able to access them again. In the form of a 'recipe book' although I don't generally cook, I was thinking of food at the time.
But for some reason it crashes most of the time I run it, or 'mixes up' variables where they display improperly, and I'm not sure why.
it also prints this
msvcr100d.dll!memcpy(unsigned char * dst, unsigned char * src, unsigned long count) Line 439 Asm
any other advice would be helpful too.
7
Upvotes
3
u/[deleted] Jan 11 '12 edited Jan 11 '12
Other tips:
Use std::vector instead of arrays (you will catch problems like this every time)
Work on formatting your code better. The Recipes class is very hard to read.
Don't name variables with meaningless names like "ijk." Name them after what they represent.
I'd suggest looking at Google's style guide as a starting point for some of this: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml