Hi, I am new to C++ programming. I bought C++ How to program Pearson International Edition by Deitel & Deitel. All the codes that were provided in the book doesn't seems to work in my compiler. I don't know much about compilers in C++. I have downloaded DEVC++ 5.0 but the code I used from the book doesn't work. I've downloaded Turbo C++ 3.0 and 4.5 and used it but still won't accept the code that is from the book.
I typed in this lines of codes from the book.
Code:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <string>
using std::string;
using std::getlin;
class GradeBook
{
public:
void setCourseName( string name )
{
courseName = name;
}
string getCourseName()
{
return courseName;
}
void displayMessage()
{
cout << "Welcome to the gradebook for \n" << getCourseName() << "!"
};
int main()
{
string nameOfCourse;
GradeBook myGradeBook;
cout << "Initial course name is: " << myGradeBook.getCourseName() << endl;
cout << "Please enter the course name" << endl;
getline( cin, nameOfCourse );
myGradeBook.setCourseName( nameOfCourse );
cout << endl;
myGradeBook.displayMessage();
}
I have checked the codes many times and compared it from the book, I just retyped it right here to show it to all of you.. When I compiled it using Turbo C++ 3.0, 4.5 it displayed lots of error messages and as well as in DevC++.
Like:
Unable to open include file 'IOSTREAM'
Declaration syntax error
Variable using is initialized more than once
Declaratino syntax error
Variable using is initialized more than once
Declaratino syntax error
Unable to open include file 'STRING'
Variable using is initialized more than once
Declaratino syntax error
'string' cannot start a parameter declaration
type name expected
Declaration missing ;
Undefined symbol 'courseName'
and lots more
I typed in a small code..
Code:
#include <iostream>
#include <string>
int main( void )
{
string name;
cout << "Enter name: "; getline( cin, name );
return 0;
}
It produced an error message still:
Unable to open include file 'IOSTREAM'
Unable to open include file 'STRING'
Undefined symbol 'string'
Statement missing;
Undefined symbol 'cin'
Undefined symbol 'name'
Function 'getline' should have a prototype
Undefined symbol 'name'
I cannot really understand what's happening. I've checked the include and library directories.. They are all correct because I was able to input some C codes and compiled it successfully but when I input C++ codes using the book I have it's not working, it's showing hundreds of error messages.
I hope that someone could help me with this.. Hope to hear from all of the masters in C++...