I am trying to write a file with extension h and a cpp file. When i try to compile the cpp file it gives me an error that says. [Linker error] undefined reference to `counter::counter()' . Could anyone help me out please. I am using a Dev.c++ compiler
Here are the classes below.
// File: counter.h
#ifndef COUNTER_H
#define COUNTER_H
class counter
{
public:
counter();
counter(int);
void increment();
void decrement();
void setcount(int);
void setmaxv(int);
int getcount() const;
int getmaxv() const;
private:
int count;
int maxv;
};
#endif // COUNTER_H
THIS IS THE CPP FILE
#include "counter.h"
#include <iostream>
using namespace std;
int main()
{
counter c1;
counter c2(10);
c1.setcount(50);
c1.decrement();
c1.decrement();
c1.increment();
cout << "Finav c1" << " " << c1.getcount() << endl;
c2.increment();
c2.increment();
c2.decrement();
cout << "Final c2 " << c2.getcount() << endl;
return 0;
}