I'm having some issues with compiling a program using a class inside of a header file. I believe that I set up the project and linker settings right, but it seems no matter what I try, it gives me an error. I've searched all over forums and i"m at my wit's end...
some background information: my IDE is code::blocks(for windows), and in the linker settings I've included "header.o" and "Main.o"
the code:
Main.cpp:
#include<iostream>
#include"Header.h"
using namespace std;
int main()
{
Pizza ob;
}
Header.h:
#ifndef HEADER_H
#define HEADER_H
class Pizza
{
public:
Pizza();
protected:
private:
};
#endif
header.cpp:
#include "Header.h"
#include <iostream>
using namespace std;
Pizza::Pizza()
{
cout << "linked!";
}
the errors I get when compiling:
obj\Debug\Header.o||In function `ZN5PizzaC2Ev':|
H:\New Build Target pro\Headertest\Header.cpp|6|multiple definition of `Pizza::Pizza()'|
obj\Debug\Header.o:H:\New Build Target pro\Headertest\Header.cpp|6|first defined here|
obj\Debug\Header.o||In function `ZN5PizzaC2Ev':|
H:\New Build Target pro\Headertest\Header.cpp|6|multiple definition of `Pizza::Pizza()'|
obj\Debug\Header.o:H:\New Build Target pro\Headertest\Header.cpp|6|first defined here|
obj\Debug\Main.o||In function `main':|
H:\New Build Target pro\Headertest\Main.cpp|8|multiple definition of `main'|
obj\Debug\Main.o:H:\New Build Target pro\Headertest\Main.cpp|8|first defined here|
||=== Build finished: 6 errors, 0 warnings (0 minutes, 7 seconds) ===|
That's just about all I've done with it. I've searched these errors and came up with just about nothing. Please help, if there's any more information I should include, please ask me About it.