When I try to compile the second file in Visual Studio 2010, it gives the error of multiply defined symbols, which makes sense since it compiles both and thus includes iostream twice, causing "one or more multiply defined symbols found" error to come up. So, I thought maybe I could use include guards to prevent this, but as I understand it, you must add the guards to files that you are including. What is the proper course of action here?
1.cpp
#include <iostream>
using namespace std;
int main()
{
int x;
cout << "**********************************" << endl
<< "* Programming Assignment 1 *" << endl
<< "* Computer Programming I *" << endl
<< "* Author: Cedar Mora *" << endl
<< "* Due Date: Thursday, Jan. 24 *" << endl //this isn't true
<< "**********************************" << "\n" << endl;
cout << "press any key" <<endl;
getchar();
return 0;
}
2.cpp
#include <iostream>
using namespace std;
int main()
{
cout << "bla" << endl;
return 0;
}
As a side note, is it possible just to compile one item of a project?
I wouldn't normally have asked, I'd just google the answer and there it would be, but I can't seem to make sense of this one. It's forcing me to have to open a separate project for each portion of code I write in order to make it compile.