Dev-C++ can't compile program multiple definitions

Dear fellows,
here's what i have.

//Stack.h
#ifndef STACK_H
#define STACK_H

class Stack {
Stack();
Stack(int sz);
....
};
#endif

//Stack.cpp
#include "Stack.h"

Stack :: Stack () {...}

Stack :: Stack(int sz) {...}

...

//StackMain.cpp
#include <iostream>
#include "Stack.cpp"

using namespace std;

int main()
{
Stack s;
system("PAUSE");
return 1;
}

Compilation Errors : multiple definition of `Stack::Stack()'
first defined here
multiple definition of `Stack::Stack()'
first defined here
multiple definition of `Stack::Stack(int)'
first defined here

What gives?
Help will be much appreciated.
Last edited on
#include "Stack.h" not .cpp
It worked. Thanks a lot.
But I don't understand the logic. Then definition (stack.cpp) is not
included anywhere?
You should include it in the list of input files for the compiler. The compiler will generate the object file for the linker to... link.
If you don't do so and use some function defined in stack.cpp, you'll get an undefined reference error from the linker.
Topic archived. No new replies allowed.