0

Cout Does not Name a Type

Folks, why I am getting this error even I am using "iostream and using namespace std"

Here is My Code

   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;
};

Class DateType is Derived from class PatientType and class PatientType is Dervied from Class PersonType.

cout is working everywhere but in class DateType.

Mohiyo Deen
  • 137
  • 3
  • 17

2 Answers2

3

cout<<"\nEnter Patient ID\n"; is a statement that needs to be inside a function.

This, and your other statements, are floating somewhere in the class definition. This is not syntactically valid.

This is confusing the compiler and is issuing a somewhat cryptic error.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483
1

Your code is outside any function, and this is incorrect.

Andrea
  • 6,032
  • 2
  • 28
  • 55