I'm using VS 2010 and I always get multiple error messages:
'<<': no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion). I get that for lines 36 and 52.
Then I get "Intellisense: no operator "<<" matches these operands for lines 36 and 51.
"Intellisense: cannot open source file "stream"
warningC4627: '#include <stream>': skipped when looking for precompiled header use
When I try to run without debugging it says '"filepath name"' is not recognized as an internal or external command, operable program or batch file.
What's wrong with my code? I copied it write out of a tutorial book and am very confused.
// Fig37.cpp : Defines the entry point for the console application.
// Instantiating multiple objects of the GradeBook name and using
// the GradeBook constructor to specify the course name
// when each GradeBook object is created
#include <iostream>
#inclide <stream>
#include "StdAfx.h"
using namespace std;
// GradeBook class definition
class GradeBook
{
public:
// constructor initiliazes courseName with string supplied as argument
GradeBook( string name )
{
setCourseName( name ); // call set function to initiliaze courseName
} // end GradeBook constructor
// function to set the course name
void setCourseName( string name )
{
courseName = name; // store the course name in the object
} // end function setCourseName
// function to get the courseName
string getCourseName()
{
return courseName; // returns object's courseName
} // end function getCourseName
// display a welcome message to the gradeBook user
void displayMessage()
{
// call getCourseName to get the courseName
cout << "Welcome to the gradebook for\n" ; getCourseName()
<< "1" << endl;
} // end function displayMessage
private:
string courseName; // course name for this GradeBook
}; //end class GradeBook
// function main begins program execution
int main()
{
// create two GradeBook objects
GradeBook gradeBook1( "CS Introduction to C++ Programming" );
GradeBook gradeBook2( "CS102 Data Structures in C++" );
// display initial value of courseName for each GradeBook
cout << "gradeBook1 created for course: " << gradeBook1.getCourseName()
<< "\ngradeBook2 created for course: " << gradeBook2.getCourseName()
<< endl;
} // end main
I'm using a "New Project" -> Win32 Console Apllication ->Application Type Console Application and "Add common header files for MFC".