static constant



  • Hallo,

    ich habe eine Template Matrix Klasse und möchte nun für die Identitätsmatrix eine statische Konstante anlegen. Versucht hab ichs so:

    template <class T>
    class Matrix { 
    public:
       static Matrix<T> Identity;
    
    };
    
    Matrix<T>::Matrix<T> Matrix<T>::Identity(1, 0, 0, 0,
                                             0, 1, 0, 0,
                                             0, 0, 1, 0,
                                             0, 0, 0, 1);
    

    Aus irgend einem Grund geht es aber nicht, VS sagt mir bei der Definition:

    Error: Overloaded function "Matrix<T>::Matrix [with T=<error type>]" is not a type name

    Wo is da der Fehler?



  • Wenn mich nicht gerade alles täuscht, müsste es so lauten:

    template <typename T>
    Matrix<T> Matrix<T>::Identity(1, 0, 0, 0,
                                  0, 1, 0, 0,
                                  0, 0, 1, 0,
                                  0, 0, 0, 1);
    


  • Das ist übrigens keine Konstante.


Anmelden zum Antworten