I want to make a project, have 3 files:
main.cpp
header.h
declerations.cpp where i have all the function declarations.
But I'm not sure how to link them all together.
When I make a header file, it automatically types the #ifndef header_h but I thoguht that should be in the declerations.cpp??
Let's say I have 3 files:
main.cpp
//main.cpp
#include <iostream>
int main()
{
test();
return 0;
}
}
header.h
//header.h
void test();
and declerations.cpp
//declerations.cpp
void test()
{
cout <<"This is from the function test in declerations.cpp";
}
But how should the linking look (where should I have my #includes? should i include both declerations and header to the main.cpp? or...? :///)
I was told that you need the #ifndef so that you don't declare the same thing twice.
But shouldn't you use #ifndef on everything then? for example iostream?