I am having trouble using cin.getline and classes. Here is the code
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <fstream>
using namespace std;
class RememberPlans
{
public:
string date;
string subject;
string resources;
string description;
};
RememberPlans nds;
// Function Prototypes
bool enterPlans(RememberPlans& nds);
void exportData(RememberPlans& nds);
void displayData(RememberPlans& nds);
int main()
{
const int MAX = 10;
RememberPlans nds[MAX];
int index = 0;
while (enterPlans(nds[index]) && index < MAX)
{
index++;
}
system("CLS");
cout << "Here are the lesson plans you entered:\n";
// Output the entries
for (int i = 0; i < index; i++)
{
cout.width(3);
displayData(nds[i]);
}
cout << "Time to export plans!";
system("PAUSE");
// Output the entries
for (int i = 0; i < index; i++)
{
cout.width(3);
exportData(nds[i]);
}
system("PAUSE");
return 0;
}
bool enterPlans(RememberPlans& nds)
{
cout << "This program creates lesson plan documents.\nType export to view and export the the plans.\n\n";
cout << "Enter subject: ";
cin.getline(nds.subject, 50);
if(nds.subject == "export" || nds.subject == "EXPORT")
{
return false;
}
cout << "\nEnter date: ";
cin.getline(nds.date, 50);
cout << "\nEnter resources (seperate with '-'): ";
cin.getline(nds.resources, 250);
cout << "\nEnter a brief descrition: ";
cin.getline(nds.description, 500);
cout << "\n";
system("CLS");
return true;
}
void exportData(RememberPlans& nds)
{
ofstream LessonData ("LessonPlans.txt", std::ios::app);
LessonData << "Date: ";
LessonData << nds.date;
LessonData << "\nSubject: ";
LessonData << nds.subject;
LessonData << "\nResources: ";
LessonData << nds.resources;
LessonData << "\nDescription: ";
LessonData << nds.description;
LessonData << "\n\n";
LessonData.close();
}
void displayData(RememberPlans& nds)
{
cout << "Date: "
<< nds.date
<< "\nSubject: "
<< nds.subject
<< "\nResources: "
<< nds.resources
<< "\nDescription: "
<< nds.description
<< "\n\n";
}
here is what my compiler gives me:
Compiling...
cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
LessonPlans.cc
c:\documents and settings\alex muir\my documents\visual studio 2008\projects\lessonplans\lessonplans.cc(60) : error C2661: 'std::basic_istream<_Elem,_Traits>::getline' : no overloaded function takes 1 arguments
with
[
_Elem=char,
_Traits=std::char_traits
]
c:\documents and settings\alex muir\my documents\visual studio 2008\projects\lessonplans\lessonplans.cc(68) : error C2661: 'std::basic_istream<_Elem,_Traits>::getline' : no overloaded function takes 1 arguments
with
[
_Elem=char,
_Traits=std::char_traits
]
c:\documents and settings\alex muir\my documents\visual studio 2008\projects\lessonplans\lessonplans.cc(71) : error C2661: 'std::basic_istream<_Elem,_Traits>::getline' : no overloaded function takes 1 arguments
with
[
_Elem=char,
_Traits=std::char_traits
]
c:\documents and settings\alex muir\my documents\visual studio 2008\projects\lessonplans\lessonplans.cc(74) : error C2661: 'std::basic_istream<_Elem,_Traits>::getline' : no overloaded function takes 1 arguments
with
[
_Elem=char,
_Traits=std::char_traits
]
Any help greatly appreciated