Problem whith gnu compiler

Iam creat class the code is
//////////////////////// ebd.h////////////////////////////

#include <iostream>

using namespace std;

class ebd
int x;
int y;
ebd (int a , int b );

int out();


////////////////////////////////////////// ebd.cpp/////////////////////////////////////

#include "ebd.h"

ebd::ebd (int a , int b )
cout << "const";

x = a;
y = b;
cout << "\nThe result of sum " << x+y<<"\n";
cout << "Enter The num\n";
cin >> x >> y;
int z;
z = x+y;
cout << "\nThe sum = " << z;


/////////////////////////////// int main()////////////////////////////////////////

int main()
ebd p(5,6);
cout <<p.out();
return 0;

but the compiler show me this messege

main.cpp|1|fatal error: ebd.h: No such file or directory|

So, where is it? If it isn't in the same directory you need to tell the compiler where it is.
What the compiler is telling you is: "I can't find the file you asked me to include, can you help me find it?" Okay, maybe not directly but the point is you have to make sure the header and the source are in the same directory(that's when you can use "header.h"), otherwise, you would have to give it the absolute/relative path to the header(something like #include "../include/path/to/header.h").

That aside, in your implementation of ebp::out, you forgot to specify the return type -- which obviously would result in an error.
Thank you for answer
Just some advice, "using namespace std;" would be more appropriately placed in the ebd.cpp file. For your personal code, it couldn't matter less. If you release this in a library that people could cause problems.

Edit: I realize that putting that line inside the edb.cpp file would force you to write it again in whatever file contains main(), but like I said before, it could save someone else using your code some headaches. For example, they couldn't use names like left, hex, and count anymore.
Last edited on
Topic archived. No new replies allowed.