header file basic question: | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

header file basic question:

//call.cpp #include "add.h" #include<iostream> using namespace std; int main() { cout<<addd(2,3); return 0; } //add.cpp #include "add.h" #include<iostream> using namespace std; int addd(int a,int b) return a+b; //add.h #ifndef ADD_H_ #define ADD_H_ using namespace std; int addd(int a,int b); #endif // ADD_H_ when i compile cal.cpp it give undefined behaviour of addd() please help where i have done wrong

19th Oct 2018, 4:25 AM
Bahubali
Bahubali - avatar
6 Answers
0
it is not working if i put curly braces
19th Oct 2018, 4:35 AM
Bahubali
Bahubali - avatar
0
i put curly braces around return statement then i compile cal.cpp again but it says undefined reference to addd(int ,int)
19th Oct 2018, 4:37 AM
Bahubali
Bahubali - avatar
0
int addd(int a,int b) { return a+b; }
19th Oct 2018, 4:41 AM
Bahubali
Bahubali - avatar
0
when i compile Add.h it says undefined reference to main
19th Oct 2018, 4:43 AM
Bahubali
Bahubali - avatar
0
i am using codeblocks
19th Oct 2018, 4:44 AM
Bahubali
Bahubali - avatar
0
ok thanks
19th Oct 2018, 4:48 AM
Bahubali
Bahubali - avatar