c++ - 多级继承错误 "cout does not name a type"

标签 c++ inheritance

Cout Does not Name a Type

伙计们,为什么我在使用“iostream 和使用命名空间标准”时会收到此错误

这是我的代码

   class DateType: public PatientType{

    cout<<"\nEnter Patient ID\n";
    cin>>Patient_ID;
    cout<<"\nEnter  Patient's Age\n";
    cin>>Age;
    cout<<"\nEnter Patient's Date of Birth";
    cin>>DOB;
};

类 DateType 派生自类 PatientType,类 PatientType 派生自类 PersonType。

cout 在任何地方都有效,但在类 DateType 中除外。

最佳答案

cout<<"\nEnter Patient ID\n";是一个语句,需要在函数中。

这和您的其他陈述都在类定义中的某处 float 。这在语法上是无效的。

这会混淆编译器并发出一个有点神秘的错误。

关于c++ - 多级继承错误 "cout does not name a type",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40398786/

相关文章:

c++ - 无法访问同一类型对象中的私有(private)成员

c# - 使用接口(interface)在 C# 中隐藏类

c# - C#中的类和基类继承

c# - 升级到 Moq 上的接口(interface)不起作用

java - 如何在两个不同的 Swing 窗口之间共享方法?

c++ - 将其地址作为参数传递的函数

c++ - 使用 boost spirit x3 解析逗号分隔的 0 个或多个列表

c++ - 将 git 命令挂接到 visual studio 预构建步骤

c++ - 不知道使用 google-test 在哪里抛出异常

html - 行高没有正确继承