Errors: Redefinition of class and Previous Definition of class in C++
<p>When I try to run the class with the class <code>counter.cpp</code>, I get the following error </p>

<pre><code>In file included from Bounded_Counter.h:7:0,
                 from counterApp.cpp:4:
Lower_Bounded_Counter.h:9:7: error: redefinition of âclass LowerBoundedCounterâ
Lower_Bounded_Counter.h:9:7: error: previous definition of âclass LowerBoundedCounterâ
In file included from Bounded_Counter.h:8:0,
                 from counterApp.cpp:4:
Upper_Bounded_Counter.h:9:7: error: redefinition of âclass UpperBoundedCounterâ
Upper_Bounded_Counter.h:9:7: error: previous definition of âclass UpperBoundedCounterâ
</code></pre>

<p>I am aware that I am including some classes twice, but I don't know how to find it. Can you please help me find what I am doing wrong? There are 4 classes <code>Counter.h, LowerBoundedCounter.h, UpperBoundedCounter.h,</code> and <code>BoundedCounter.h</code>. <code>LowerBoundedCounter.h</code> and <code>UpperBoundedCounter.h</code> both include the <code>Counter.h</code> file. <code>BoundedCounter.h</code> includes both the <code>LowerBoundedCounter.h</code> and the <code>UpperBoundedCounter.h</code> files. The implementation file is <code>counterApp.cpp</code> (not provided here)</p>

<p>Here is the Counter.h class.</p>

<pre><code>#ifndef COUNTER_H
#define COUNTER_H

#include &lt;iostream&gt;

class Counter{
        private:
                int val;
        public:
                Counter():val(0) {}

                Counter(int val):val(val){}

                void up(){
                        this-&gt;val++;
                }

                void down(){
                        this-&gt;val--;
                }

                int getVal() const {
                        return this-&gt;val;
                }

                friend std::ostream &amp;operator &lt;&lt;(std::ostream &amp;os, const Counter &amp;counter) {
                        os &lt;&lt; "A Counter with a value of " &lt;&lt; counter.val;
                        return os; 
                }

};

#endif
</code></pre>

<p>Here is LowerBoundedCounter.h class. This class contains a 'Counter' object.</p>

<pre><code>#ifndef LOWER_BOUNDED_COUNTER_H
#define LOWER_BOUNDER_COUNTER_H

#include&lt;iostream&gt;

#include "Counter.h"


class LowerBoundedCounter{
        private:
                Counter counter;
                int limit;
        public:
                LowerBoundedCounter(int limit,int val):counter(val), limit(limit){

                }

                LowerBoundedCounter(int val):counter(val),limit(10){

                }

                LowerBoundedCounter():counter(),limit(0){

                }

                void up(){
                        if(getVal() &gt;  limit){
                                counter.up();
                        }
                }

                void down(){
                        counter.down();
                }

                int getLimit() const{
                        return this-&gt;limit;
                }

                int getVal() const{
                        return counter.getVal();
                }

                friend std::ostream &amp;operator &lt;&lt;(std::ostream &amp;os, const LowerBoundedCounter &amp;LowerBoundedCounter){
                        os &lt;&lt; "An LowerBoundedCounter with a value of " &lt;&lt; LowerBoundedCounter.getVal() &lt;&lt; " and a limit of "&lt;&lt;LowerBoundedCounter.limit;
                        return os;
                }

};

#endif
</code></pre>

<p>Here's the UpperBoundedCounter.h class</p>

<pre><code>#ifndef UPPER_BOUNDED_COUNTER_H
#define UPPER_BOUNDER_COUNTER_H

#include&lt;iostream&gt;

#include "Counter.h"

class UpperBoundedCounter{
        private:
                Counter counter;
                int limit;
        public:
                UpperBoundedCounter(int limit,int val):counter(val), limit(limit){

                }

                UpperBoundedCounter(int val):counter(val),limit(10){

                }

                UpperBoundedCounter():counter(),limit(10){

                }

                void up(){
                        if(getVal() &lt; limit){
                                counter.up();
                        }
                }

                void down(){
                        counter.down();
                }

                int getLimit() const {
                        return this-&gt;limit;
                }

                int getVal() const{
                        return counter.getVal();
                }

                friend std::ostream &amp;operator &lt;&lt;(std::ostream &amp;os, const UpperBoundedCounter &amp;UpperBoundedCounter){
                        os &lt;&lt; "An UpperBoundedCounter with a value of " &lt;&lt; UpperBoundedCounter.getVal() &lt;&lt; " and a limit of "&lt;&lt;UpperBoundedCounter.limit;
                        return os;
                }

};
</code></pre>

<p>Finally, I have objects from all 3 of the above classes in BoundedCounter.h</p>

<pre><code>#ifndef BOUNDED_COUNTER_H
#define BOUNDER_COUNTER_H

#include&lt;iostream&gt;

#include "Counter.h"
#include "Lower_Bounded_Counter.h"
#include "Upper_Bounded_Counter.h"

class BoundedCounter{
        private:
                Counter counter;
                UpperBoundedCounter upperBoundedCounter;
                LowerBoundedCounter lowerBoundedCounter;
        public:
                BoundedCounter(int val, int upperLimit, int lowerLimit):counter(val),upperBoundedCounter(upperLimit),lowerBoundedCounter(lowerLimit){

                }


                BoundedCounter(int val,int upperLimit):counter(val), upperBoundedCounter(upperLimit), lowerBoundedCounter(){

                }

                BoundedCounter(int val):counter(val),upperBoundedCounter(),lowerBoundedCounter(){

                }

                BoundedCounter():counter(), upperBoundedCounter(), lowerBoundedCounter(){

                }

                void up(){
                        if(getVal() &lt; upperBoundedCounter.getLimit() &amp;&amp; getVal() &gt; lowerBoundedCounter.getLimit()){
                                counter.up();
                        }
                }

                void down(){
                        counter.down();
                }

                int getLowerLimit() const{
                        return lowerBoundedCounter.getLimit();
                }

                int getUpperLimit() const{
                        return upperBoundedCounter.getLimit();
                }

                int getVal() const{
                        return counter.getVal();
                }

                friend std::ostream &amp;operator &lt;&lt;(std::ostream &amp;os, const BoundedCounter &amp;BoundedCounter){
                        os &lt;&lt; "An BoundedCounter with a value of " &lt;&lt; BoundedCounter.getVal() &lt;&lt; " and a lower limit of "&lt;&lt;BoundedCounter.getLowerLimit() 
                                                                                              &lt;&lt;" and a higher limit of "&lt;&lt;BoundedCounter.getUpperLimit();
                        return os;
                }

};

#endif
</code></pre>