Mohiyo Deen Mohiyo Deen - 1 year ago 225
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";
cout<<"\nEnter Patient's Age\n";
cout<<"\nEnter Patient's Date of Birth";

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

cout is working everywhere but in class DateType.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download