I've just reached chapter 5 in Accelerated C++, and in C4 it briefly described making your own data structures. I've tried to implement an address book (following a suggestion on these tutorials), I've made a struct and added the information into it, and up to there the program compiles fine. Now, when I try to output the contents like this:
(Example taken from the cprogramming tutorials) I get this compiler error:Code:#include <iostream> using namespace std; struct database { int id_number; int age; float salary; }; int main() { database employee; //There is now an employee variable that has modifiable // variables inside it. employee.age = 22; employee.id_number = 1; employee.salary = 12000.21; cout << employee; cin.get(); }
no match for ‘operator<<’ in ‘std::cout << employee’
Put simply, how do you directly output the contents of a user-defined structure?