-1
Ich möchte die T & Operator() (int x, int y) Funktion definieren, aber ich kann nicht verstehen, wie Sie es definieren. Ich habe diese Funktion in der Array.h Datei, so dass ich es in der Array.hpp Datei definieren muss, denke ich. Hat jemand eine Idee?Implementierung in Operatoren mit Vorlagen
#ifndef _ARRAY_
#define _ARRAY_
namespace math
{
/*! The Array class implements a generic two-dimensional array of elements of type T.
*/
template <typename T>
class Array
{
protected:
//! Flat storage of the elements of the array of type T
T * buffer;
unsigned int width,
height;
/* Returns a reference to the element at the zero-based position (column x, row y).
*
* \param x is the zero-based column index of the array.
* \param y is the zero-based row index of the array.
*
* \return a reference to the element at position (x,y)
*/
T & operator() (int x, int y);
};
} // namespace math
#include "Array.hpp"
#endif
Fragen Sie, wie man es außerhalb der Linie definiert? Oder wie man es umsetzt? – doctorlove
@doctorlove Ich frage, wie man es definiert, danke – madrugadas25845