Problems understanding class redifition

Hello guys !
I'm tryng understand how c++ works and oop in general work.

I'm facing some problems understanding the best practices and how to solve (probably easy) compiler errors.

I got this error : cdBox.h:9:7: error: redefinition of ‘class cdBox’
class cdBox: public Product

On this code .
https://dl.dropboxusercontent.com/u/710615/newDiamanteProject.zip

I'm sorry for being general.
You have a typo

1
2
3
//cdbox.h
#ifndef _cdBox_h_
#define _cdBox_h 

Missing an underscore ;)


Edit: And in case you don't understand why this is a problem, the compiler thinks that your cdBox class is being redefined because even after the first time you #include your cdBox header file, "_cdBox_h_" is still undefined, so it will go through all the code in that header file again, each time you wrote #include "cdBox.h" somewhere else.
Last edited on
Thanks !
I'm learning, so these kind of "errors" are new to me :)
I got it.

However, after doing the correction I got another error:

How can I print the content of the variable price, which as a default value, at the child class?
I inherited, but changed the constructor.

I've updated the code at :

https://dl.dropboxusercontent.com/u/710615/newDiamanteProject.zip


Last edited on
Topic archived. No new replies allowed.