Hello all. So for our class we have just been doing codes within one script. Now we are using header files, along with two cpp files that we are supposed to use a Makefile with. I'm using visual studio 2010 express and am not sure how to go about doing this. Any help would be grateful as I have no idea how to check if it will properly compile. We had one lecture on this, and our professor seems to assume that we all have Linux or something (the schools computer OS) as she never really outlined how to do this in Windows.
Ahh so for some reason I'm still not grasping this. Might be the 8 hours of physics I did today. Perhaps somebody could help guide me in the right direction, cause at this point even the instructions are reading like jargon to me, it's like something just isn't connecting
1 2 3 4 5 6 7
You will pass an input file’s name on the command file. Inside the main function, open this input file, read the
given course’s name followed by its prerequisites, put all prerequisites into a vector of strings temp, and
instantiate an object of type Course using the name and the vector temp as parameters to the constructor. Test
each member function: (1) print to the screen the name returned by get_name(), (2) print to the screen all
prerequisites returned by get_prereq( vector<string> &prereqs), i.e. you have to create a new empty vector of
strings and pass it to get_prereq. After calling this function, prereqs should contain all prerequisites of the
course, use for loop to print them to the screen; (3) test print() function.
Basically I need to write a program that will retrieve strings from a text file. The text file has a single line of text, the first word being a course, the next two being prerequisites to the course. So far I have:
I know that's a big post. If anybody could just point me in the right direction to a post with related info, show me where to get started, or really anything at this point, I'd be incredibly grateful. I love this class (no pun intended) and am really frustrated that I'm not understanding this.
You will pass an input file’s name on the command file.
Use argv[1] to get the filename for the input file. You already did this.
Inside the main function, open this input file, read the given course’s name followed by its prerequisites, put all prerequisites into a vector of strings temp, and instantiate an object of type Course using the name and the vector temp as parameters to the constructor.
Use a vector of strings to read all the data from the input file.
After reading is done, feed the vector to a Course object. You did this too.
Errr... where exactly are you stuck? Hint: next time be clear about it.
Test each member function: (1) print to the screen the name returned by get_name(),
(2) print to the screen all prerequisites returned by get_prereq( vector<string> &prereqs), i.e. you have to create a new empty vector of strings and pass it to get_prereq. After calling this function, prereqs should contain all prerequisites of the course, use for loop to print them to the screen;
// ...
int main(int argc, char *argv[])
{
// need a new vector of strings to feed it to Course::get_prereq()
vector<string> temp2;
course.get_prereq(temp2); // copy the Course's vector<string> data into temp2
for (int i=0; i < temp2.size(); i++)
cout << temp2[i] << ' ';
// or if you want the "proper" C++98 way to do this...
for (vector<string>::const_iterator ci = temp2.begin(); ci != temp2.end(); ++ci)
cout << *ci << ' ';
// or the "proper" C++11 way (not supported by Visual Studio 2010)
for (const string &s: temp2)
cout << s << ' ';
}