Reputation: 1
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main(){
const char *months[12]={"January", "February", "March", "April","May", "June", "July", "August","September", "October", "November", "December"}; // to check month is that true or false.
int day,year;
string first,last,month;
Person p(first,last,day,month,year);
ifstream infile; //opening input file
infile.open("input.txt");
while(!infile.eof()) {
}
}
}
I check the values in the Input file and print the correct ones in the output file.I call the setmonth function to check if the month is correct after checking if the day and year are correct in the Input file.
HOW CAN I SOLVE THIS ERROR? AND WHAT IS printInfo FUNCTION PARAMETER?
Upvotes: 0
Views: 197
Reputation: 87997
So the first problem is that you write
if(!p.setMonth(month))
which means that setMonth
should return a value that can be passed to !
. But if you look at setMonth
you see this
void setMonth(string m){}
setMonth
is a void
function, it doesn't return anything so !p.setMonth()
is illegal.
Probably it should return a bool
bool setMonth(string m) { ... }
I imagine that void printInfo(ostream){}
should be void printInfo(ostream&){}
.That's the normal way to pass an output stream to a function.
Upvotes: 1