Anytime I try to compile the code below I get the following error message.
E:\Users\Cosman\Desktop\C++ PRACTICE\read2.cpp|52|error: no match for 'operator<<' in 'std::cout << m'
How do I correct this?

#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;

class A
    char name[50];
    char gender[8];
    int age;

    A(char *n, char *g, int a);
    friend ofstream &operator<<(ofstream &target, A obj);
    friend ifstream &operator>>(ifstream &target, A obj);

A::A(char *n, char *g, int a)
    strcpy(name, n);
    strcpy(gender, g);
    age = a;

ofstream &operator<<(ofstream &target, A obj)
    return target;

ifstream &operator>>(ifstream &target, A obj)
    target.getline(, 50).getline(obj.gender, 6)>>obj.age;
    return target;

int main()
    char n[50];
    char s[8];
    int a;
    cout<<"Enter name: ";
    cin.getline(n, 50);
    cout<<"Enter gender: ";
    cin.getline(s, 8);
    cout<<"Enter age: ";
    A m(n, s, a);
    return 0;

The problem is you defined you function as using ofstream and ifstream. These are the objects used for handling files. If you want to use you class with cin and cout you need to use istream and ostream.

Thanks NathanOliver. My program now compiles.