I was working on a very simple c++ program and successfully compiled 2 classes, one a subclass of the other. However when I used them in my main, i got this compilation error. Im relatively new at C++ so I dun really understand whats going on:confused:
In file included from overdraft.h:1,
from main.cpp:3:
bankAcct.h:1: error: redefinition of `class BankAcct'
bankAcct.h:1: error: previous definition of `class BankAcct'
Deciphering of error msg
Started by boredaxel, Jan 28 2009 10:09 AM
5 replies to this topic
#1
Posted 28 January 2009 - 10:09 AM
|
|
|
#2
Posted 28 January 2009 - 10:34 AM
Are you using include guards to avoid including bankAcct.h twice?
#3
Posted 29 January 2009 - 05:28 AM
:o Indeed I was. Thanks alot for pointing that out. Didn't realise it would get me an error, got lots to learn lol.
#4
Posted 29 January 2009 - 08:05 AM
Generally with a .h file, your file will look something like this:
#ifndef __myfile_h #define __myfile_h /* code more code end code */ #endifThe tells the compiler to only include the header information once.
#5
Posted 30 January 2009 - 11:36 PM
In some compilers, a simple #pragma once at the top will do the trick too.
#6
Posted 31 January 2009 - 12:39 AM
Dev-C++ has an "add library" (if it's a project file).
Alt + P I believe.
Alt + P I believe.
“You may be disappointed if you fail, but you are doomed if you don't try.”
- Beverly Sills
- Beverly Sills


Sign In
Create Account


Back to top









