友元函数访问私有报错
报错显示未定义标识符,请问问题出在哪里,谢谢!
#include<iostream>
struct DataType
{
int ID;//编号
char name[10];//姓名
char ch;//性别
char phone[13];//电话
char addr[31];//地址
};
class Contact
{
public:
Contact();
Contact(int ID, char* name, char* ch, char* phone, char* addr);
~Contact();
void addContact(int ID, char* name, char* ch, char* phone, char* addr);
friend void deleteContact(char* name);
friend int GetLength();
private:
DataType person[100];
int m_ID;
char* m_name;
char* m_ch;
char* m_phone;
char* m_addr;
int length;
};
Contact::Contact()
{
person == new struct DataType;
}
Contact::Contact(int ID, char* name, char* ch, char* phone, char* addr)//构造
{
m_ID = ID;
m_name = name;
m_ch = ch;
m_phone = phone;
m_addr = addr;
}
void deleteContact(char* name)//删除联系人
{
//首先查找联系人
cout << "请输入要删除的联系人姓名:";
cin >> name;
int i = Locate(name);
//删除
DataType x = person[i - 1];
for (int j = i; j < length; j++)
person[j - 1] = person[j];
length--;
return x;
}
int GetLength()
{
return length;
}