Mohiyo Deen Mohiyo Deen - 1 month ago 13
C++ Question

Multilevel Inheritance Error "cout does not name a type"


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.

Answer

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.

Comments