c++ - error LNK2019: Verweis auf nicht aufgelöstes externes Symbol - Ich finde den Fehler nicht

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • c++ - error LNK2019: Verweis auf nicht aufgelöstes externes Symbol - Ich finde den Fehler nicht

    Hallo,
    ich muss für eine Prüfung C++ lernen und mache dafür jetzt einige Übungen durch. Leider finde ich bei dieser Aufgabe den Fehler nicht. Ob das Programm macht was es soll, soll hier gar nicht überprüft werden. Das möchte ich selber machen. Es geht mir nur um die Syntax. Ich hoffe jemand von euch sieht was falsch ist, damit ich endlich weiter komme.
    Gruß

    Die Fehlermeldung:
    1>main.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: class CommaProxy __thiscall MatrixT<2,3>::operator=(double)" (??4?$MatrixT@$01$02@@QAE?AVCommaProxy@@N@Z)" in Funktion "_main".
    1>C:\Users\Phil\Documents\Visual Studio 2010\Projects\matrixN\Debug\matrixN.exe : fatal error LNK1120: 1 nicht aufgelöste externe Verweise.
    1>
    1>Fehler beim Erstellen

    Der Code:

    C-Quellcode

    1. //main.cpp
    2. #include <iostream>
    3. #include "MatrixT.h"
    4. using namespace std;
    5. int main(void)
    6. {
    7. MatrixT<2,3> m;
    8. m = 1, 2, 3,
    9. 4, 5, 6;
    10. cout << m;
    11. cin.get();
    12. return 0;
    13. }
    Alles anzeigen


    C-Quellcode

    1. //MatrixT.h
    2. #pragma once
    3. #include "CommaProxy.h"
    4. #include <iostream>
    5. template <size_t R, size_t C>
    6. class MatrixT
    7. {
    8. public:
    9. double operator()(size_t row, size_t col) const;
    10. double& operator()(size_t row, size_t col);
    11. CommaProxy operator=(double value);
    12. private:
    13. double data[R][C];
    14. template <size_t RR, size_t CC>
    15. friend std::ostream& operator<<(std::ostream& os, const MatrixT <RR, CC> &m);
    16. };
    Alles anzeigen


    C-Quellcode

    1. //MatrixT.cpp
    2. #include "MatrixT.h"
    3. #include "CommaProxy.h"
    4. #include <iostream>
    5. #include <stdexcept>
    6. using namespace std;
    7. template <size_t R, size_t C>
    8. double MatrixT<R,C>::operator() (size_t row, size_t col) const
    9. {
    10. if (row >= R || col >= C) throw runtime_error("Matrix error");
    11. return data[row][col];
    12. }
    13. template <size_t R, size_t C>
    14. double& MatrixT<R,C>::operator()(size_t row, size_t col)
    15. {
    16. if (row >= R || col >= C) throw runtime_error("Matrix error");
    17. return data[row][col];
    18. }
    19. template <size_t R, size_t C>
    20. CommaProxy MatrixT<R,C>::operator=(double value)
    21. {
    22. return CommaProxy(&data[0][0], &data[0][0] + R * C), value;
    23. }
    24. template <size_t RR, size_t CC>
    25. ostream& operator<<(ostream& os, const MatrixT<RR,CC> &m)
    26. {
    27. for (size_t r = 0; r < RR; r++) {
    28. os << "|";
    29. for (size_t c = 0; c < CC; c++) os << m(r,c) << "|";
    30. os << endl;
    31. }
    32. return os;
    33. }
    Alles anzeigen


    Quellcode

    1. //CommaProxy.h
    2. #pragma once
    3. class CommaProxy
    4. {
    5. public:
    6. CommaProxy(double *p, double *end);
    7. ~CommaProxy(void);
    8. CommaProxy& operator,(double value);
    9. private:
    10. double *p;
    11. double *end;
    12. };
    Alles anzeigen


    C-Quellcode

    1. //CommaProxy.cpp
    2. #include "CommaProxy.h"
    3. #include <stdexcept>
    4. using namespace std;
    5. CommaProxy::CommaProxy(double *p, double *end)
    6. {
    7. this->p = p;
    8. this->end = end;
    9. }
    10. CommaProxy::~CommaProxy(void)
    11. {
    12. delete p;
    13. delete end;
    14. }
    15. CommaProxy& CommaProxy::operator,(double value)
    16. {
    17. if (p == end) throw runtime_error("Speicherüberlauf");
    18. *(p++) = value;
    19. return *this;
    20. }
    Alles anzeigen