[英]Error C2228: Expression must have class type
I feel like this should be very easy portion of my project but I don't see how to fix this error. 我觉得这应该是我项目中非常简单的部分,但是我看不到如何解决此错误。 Does the error involve misuse of the pointer on *fout.open?
该错误是否涉及滥用* fout.open上的指针?
void GetOutput(std::ofstream * fout, std::string filename)
{
*fout.open(filename, std::ios::out);
}
Do this: 做这个:
(*fout).open(filename, std::ios::out);
or this: 或这个:
fout->open(filename, std::ios::out);
But, really, both arguments to your function should be references, the second one should be a const reference. 但是,实际上,函数的两个参数都应该是引用,第二个参数应该是const引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.