[try Beta version]
Not logged in

 
I can't work with multiple files!

May 25, 2013 at 9:32am
The compiler doesn't allow me to use multiple files for some reason?! Please help!

My files:

Main.cpp
1
2
3
4
5
6
7
#include <iostream>
#include "proto.h"
using namespace std;

int main(){
add(3,4);
}


Implementation.cpp
1
2
3
4
5
6
7
#include <iostream>
#include "proto.h"
using namespace std;

int add(int x, int y){
    return x+y;
}


Proto.h
1
2
3
4
5
6
#ifndef PROTO_H_INCLUDED
#define PROTO_H_INCLUDED

int add(int x, int y);

#endif 


ERROR RECEIVED:
C:\Users\Kalist\Desktop\C++\Projects\Console\main.cpp||In function `int main()':|
C:\Users\Kalist\Desktop\C++\Projects\Console\main.cpp|6|error: `add' undeclared (first use this function)|
C:\Users\Kalist\Desktop\C++\Projects\Console\main.cpp|6|error: (Each undeclared identifier is reported only once for each function it appears in.)|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 0 seconds) ===|
May 25, 2013 at 9:46am
Did you add implementation.cpp in to compile list of your project?
May 25, 2013 at 10:22am
It looks to me as though the #include "proto.h" failed to find or read the correct header file. However, if that was the case, there should have been an error message to indicate that problem.

Is it possible that there is more than one file named "proto.h" and the wrong one is being used?
Topic archived. No new replies allowed.