This is my template matrix class:
template<typename T>
class Matrix
{
public:
....
Matrix<T> operator / (const T &num);
}
However, in my Pixel class, I didn't define the Pixel/Pixel operator at all!
Why in this case, the compiler still compiles?
Pixel class
#ifndef MYRGB_H
#define MYRGB_H
#include <iostream>
using namespace std;
class Pixel
{
public:
// Constructors
Pixel();
Pixel(const int r, const int g, const int b);
Pixel(const Pixel &value);
~Pixel();
// Assignment operator
const Pixel& operator = (const Pixel &value);
// Logical operator
bool operator == (const Pixel &value);
bool operator != (const Pixel &value);
// Calculation operators
Pixel operator + (const Pixel &value);
Pixel operator - (const Pixel &value);
Pixel operator * (const Pixel &value);
Pixel operator * (const int &num);
Pixel operator / (const int &num);
// IO-stream operators
friend istream &operator >> (istream& input, Pixel &value);
friend ostream &operator << (ostream& output, const Pixel &value);
private:
int red;
int green;
int blue;
};
#endif