Jump to content

Deciphering of error msg

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
boredaxel

boredaxel

    Newbie

  • Members
  • PipPip
  • 10 posts
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'

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Are you using include guards to avoid including bankAcct.h twice?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
boredaxel

boredaxel

    Newbie

  • Members
  • PipPip
  • 10 posts
: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
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Generally with a .h file, your file will look something like this:
#ifndef __myfile_h
#define __myfile_h

/* code
more code
end code */
#endif
The tells the compiler to only include the header information once.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,714 posts
In some compilers, a simple #pragma once at the top will do the trick too.

#6
Muted

Muted

    Learning Programmer

  • Members
  • PipPipPip
  • 86 posts
Dev-C++ has an "add library" (if it's a project file).
Alt + P I believe.
“You may be disappointed if you fail, but you are doomed if you don't try.”
- Beverly Sills