Functions with bool parameter
Dec 7, 2014 at 12:06pm UTC
Hi,
I have this function:
1 2 3 4 5 6 7 8 9 10 11 12 13
String^ Column0(string pathname){
String^ str1;
ifstream fin(pathname);
{
string str;
while (getline(fin, str)){
if (myBool(str))
str1 = gcnew String(str.substr(5).c_str());
}
}
fin.close();
return str1;
}
I am unsure how to add a bool parameter to this function; myBool needs to be the second parameter. I have tried the following for line 1 by I get errors:
String^ Column0(string pathname, bool myBool){...
.
What do I need to do?
Cheers,
Last edited on Dec 7, 2014 at 12:07pm UTC
Dec 7, 2014 at 12:15pm UTC
Ha!
Nevermind. I solved it... Well this code works anyway:
1 2 3 4 5 6 7 8 9 10 11 12 13
String^ Column0(string pathname, bool myBool(const std::string & str)){
String^ str1;
ifstream fin(pathname);
{
string str;
while (getline(fin, str)){
if (myBool(str))
str1 = gcnew String(str.substr(5).c_str());
}
}
fin.close();
return str1;
}
Last edited on Dec 7, 2014 at 12:15pm UTC
Topic archived. No new replies allowed.