简体   繁体   English

错误C2228:表达式必须具有类类型

[英]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.

相关问题 错误:C2228:“”的左侧必须具有class / struct / union - Error: C2228: left of '' must have class/struct/union 错误22错误C2228:'.size'的左侧必须具有class / struct / union - Error 22 error C2228: left of '.size' must have class/struct/union 错误C2228:'。Alloc'的左边必须有class / struct / union - error C2228: left of '.Alloc' must have class/struct/union 错误C2228:“。x”的左侧必须具有class / struct / union - error C2228: left of '.x' must have class/struct/union 在异常情况下,C ++错误C2228('。''的左边必须有class / struct / union) - C++ Error C2228 (left of '.val' must have class/struct/union) in unusual circumstances 错误C2228:'。size'的左边必须有class / struct / union - error C2228: left of '.size' must have class/struct/union 获取错误代码C2228:“ ._ Ptr”的左侧必须具有class / struct / union - Getting error code C2228: left of '._Ptr' must have class/struct/union 错误C2228:'.DXGI_MODE'的左边必须有class / struct / union Direct X. - error C2228: left of '.DXGI_MODE' must have class/struct/union Direct X 错误C2228:'。words'的左边必须有class / struct / union - error C2228: left of '.words' must have class/struct/union 错误C2228:'.draw'的左边必须有class / struct / union - error C2228: left of '.draw' must have class/struct/union
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM