Name: Newbie Programmer 2008-01-12 21:51
I'm new to C++. I'm trying to use "getline" in my program to accept character and whitespace inbetween but I get some error in Borland.
/* This program defines class GradeBook with a
member function that takes a parameter; */
#include <iostream>
#include <string>
#include <conio.h>
class GradeBook
{
public:
void displaymessage (string coursename)
{
cout << "\nWelcome to the Grade Book System\n\nThe name of your course is " << coursename <<endl;
}
};
int main ()
{
string NameOfCourse;
GradeBook mygradebook;
cout << "Please Enter the name of your course: " <<endl;
getline (cin, NameOfCourse); /* "Call to undefined function 'getline' error" */
// cin >> NameOfCourse; //White space ends insertion operator
mygradebook.displaymessage (NameOfCourse);
getch();
return 0;
}
/* This program defines class GradeBook with a
member function that takes a parameter; */
#include <iostream>
#include <string>
#include <conio.h>
class GradeBook
{
public:
void displaymessage (string coursename)
{
cout << "\nWelcome to the Grade Book System\n\nThe name of your course is " << coursename <<endl;
}
};
int main ()
{
string NameOfCourse;
GradeBook mygradebook;
cout << "Please Enter the name of your course: " <<endl;
getline (cin, NameOfCourse); /* "Call to undefined function 'getline' error" */
// cin >> NameOfCourse; //White space ends insertion operator
mygradebook.displaymessage (NameOfCourse);
getch();
return 0;
}