Hi @lastchance. I will post again all files. And all errors. I made a completely new project for this, without any other classes out commented:
.h file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#ifndef REEE_H
#define REEE_H
//#include "deque"
#include "iostream"
using namespace std;
template<typename IntContainer>
class reee
{
public:
reee(const IntContainer& ds);
reee();
void addone(int x);
int val{};
IntContainer vald;
IntContainer add_val2(const IntContainer& a);
};
#endif // REEE_H
|
cpp.file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include "reee.h"
template<typename IntContainer>
reee<IntContainer>::reee(const IntContainer& ds)
{
for(unsigned int i{};i<ds.size();i++)
{
cout<<"hi!"<<endl;
}
}
template<typename IntContainer>
reee<IntContainer>::reee()
{
// for(unsigned int i{};i<ds.size();i++)
{
cout<<"hi!"<<endl;
}
}
template<typename IntContainer>
void reee<IntContainer>::addone(int xs)
{
val=+xs;
cout<<"val:"<<val<<endl;
}
template<typename IntContainer>
IntContainer reee<IntContainer>::add_val2(const IntContainer& a)
{
return vald=a;
}
|
main file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
/*
* Muster.cpp
*
*/
#include "reee.h"
#include <deque>
int main()
{
try
{
deque<int> cont1;
cont1.push_back(5);
auto test1 {reee (cont1)};
test1.addone(4);
reee<std::deque<int>> test3(cont1);
reee<deque<int>>test2(cont1);
test2.addone(3);
return 0;
}
catch( std::exception& e ) {
cerr << "Ausnahme: " << e.what()<<endl;
return -3;
}
catch( ... ) {
cerr << "Unbekannte Ausnahme"<<endl;
return -1;
}
}
|
Errors complete (with file path)(Fehler=error):
C:\Users\User\Documents\Pad2ss21\build-p4_tst2-Desktop_Qt_6_1_1_MinGW_64_bit-Debug\..\p4_tst2\main.cpp:17: Fehler: undefined reference to `reee<std::deque<int, std::allocator<int> > >::reee(std::deque<int, std::allocator<int> > const&)'
debug/main.o: In function `main':
C:\Users\User\Documents\Pad2ss21\build-p4_tst2-Desktop_Qt_6_1_1_MinGW_64_bit-Debug/../p4_tst2/main.cpp:17: undefined reference to `reee<std::deque<int, std::allocator<int> > >::reee(std::deque<int, std::allocator<int> > const&)'
C:\Users\User\Documents\Pad2ss21\build-p4_tst2-Desktop_Qt_6_1_1_MinGW_64_bit-Debug\..\p4_tst2\main.cpp:18: Fehler: undefined reference to `reee<std::deque<int, std::allocator<int> > >::addone(int)'
C:\Users\User\Documents\Pad2ss21\build-p4_tst2-Desktop_Qt_6_1_1_MinGW_64_bit-Debug\..\p4_tst2\main.cpp:20: Fehler: undefined reference to `reee<std::deque<int, std::allocator<int> > >::reee(std::deque<int, std::allocator<int> > const&)'
C:\Users\User\Documents\Pad2ss21\build-p4_tst2-Desktop_Qt_6_1_1_MinGW_64_bit-Debug\..\p4_tst2\main.cpp:21: Fehler: undefined reference to `reee<std::deque<int, std::allocator<int> > >::reee(std::deque<int, std::allocator<int> > const&)'
C:\Users\User\Documents\Pad2ss21\build-p4_tst2-Desktop_Qt_6_1_1_MinGW_64_bit-Debug\..\p4_tst2\main.cpp:22: Fehler: undefined reference to `reee<std::deque<int, std::allocator<int> > >::addone(int)'
:-1: Fehler: collect2.exe: error: ld returned 1 exit status
:-1: Fehler: [Makefile.Debug:71: debug/p4_tst2.exe] Error 1
Errors are from line 15 to 20 without line 17 on the main file. It does not compile