为什么cout未定义在我的cpp中,如果它包含在我的标题中?

-4 c++ inheritance

我有一个有#include iostream的班级啊

然后在Bh我#include啊

然后在Ch我#include Bh

在C.cpp中,我将print()函数定义为

void C::print() const {
cout << "C has specs of: " << getSpecs() << endl;
} 
Run Code Online (Sandbox Code Playgroud)

对于C.cpp,cout是不确定的为什么会这样?

我认为,因为iostream被包含在Ah中,因为Bh包括Ah和Ch包括Bh,所以它将包括iostream用于我的C.cpp

无论如何在没有#including iostream的情况下完成这个我的所有.h's?

我很擅长继承并学习如何运作.

fuz*_*g44 5

cout在命名空间中std.使用std::coutstd::endl不是coutendl.