You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

C++编译报错:类sala中未声明成员函数inici求助

Fixing the "no member function declared" error for sala::inici

That error tells us the compiler can't find the declaration of inici(int, int) in your sala class, even though you’ve clearly added it to the header. Let’s walk through the most likely fixes tailored to your situation:

  • Make sure you saved your sala.hh file: It’s an easy oversight—if you added the inici declaration but didn’t save the header before compiling, the compiler will still use the old version without that function. Hit save and recompile.

  • Do a clean build: Sometimes build systems (like Makefiles) fail to detect changes to header files, reusing old compiled object files instead. Delete any .o or .obj files generated from your code, then recompile everything from scratch. This ensures the compiler picks up the latest version of your header.

  • Confirm you’re including the correct header: If there are multiple copies of sala.hh in different directories, your compiler might be picking up an older version that lacks the inici function. Double-check that the #include "sala.hh" line in sala.cc points to the file you edited (this is usually non-issue if they’re in the same folder, but worth verifying).

  • Check for hidden syntax errors: A missing semicolon or brace earlier in the header could cause the compiler to misparse the class definition. Your private section and constructor/destructor declarations look correct, but it’s worth a quick second pass to ensure no typos are hiding the inici declaration.

Since your posar_prod function compiles fine, we know the header is being included correctly in sala.cc. The problem is almost certainly related to the compiler not seeing the updated inici declaration in the header—starting with saving the file and doing a clean build should resolve this quickly.

内容的提问来源于stack exchange,提问作者minoru

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:49:59