Hello,
I am new to C++ and am trying to learn about operator overloading. I can not seem to wrap my mind around how it works. Could someone please point me in the right direction.
PHP Code:
#include <iostream>
#include <string>
using namespace std;
//--- CLASSES ---
class contact
{ private: char fname[6];
char number[6];
public:
void get();
void show();
bool operator == (emp);
};
//--- FUNCTIONS ---
void contact::get()
{ cout<< "name: ";
cin.getline(fname,6);
cout<< "number: ";
cin>> number;
}
bool emp::operator == (emp find)
{
*ptr[0]==find; // I would like to be able to search by
} // fname or by number. I jsut can't figure
// out the syntax and what am I passing
//--- PROGRAM BODY ---
int main()
{ emp *ptr[2];
emp find;
ptr[0]=new emp;
ptr[0]->get();
cout<< "Find: ";
cin>> find;
if(*ptr[0]==find)
cout << "Pass = 1 \n";
else cout<< "Fail = 0\n";
system("PAUSE");
return 0;
}