Operator overloading for user-defined types (part 1)
On this page
This lesson contains approximately 15 minutes of video content.
Introduction
First concepts
Calling an overloaded operator
Member or nonmember implementation?
In this problem, you will overload the equal to operator (
operator==) for Student typed objects. We consider two student objects equivalent if each of their data members store identical values.
#include <iostream>
#include "student.hpp"
#include "utilities.hpp"
int main() {
}
#ifndef STUDENT_HPP
#define STUDENT_HPP
#include <string>
struct Student {
std::string first_name;
std::string last_name;
unsigned int uin;
};
#endif
#include "student.hpp"
#ifndef UTILITIES_HPP
#define UTILITIES_HPP
#include "student.hpp"
#endif
#include "utilities.hpp"
> Click Run to compile and run your code.