how fix missing template arguments before 'test'

i need use 3 class , + operator, vector and template but i get error
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <iostream>
#include <string.h>
#include<vector>
#include <iostream>
#include <fstream>
#include<windows.h>
#include <stdio.h>
using namespace std;

class cars{
protected:
    string a_marke,a_modelis, var_turis,maks_grietis;
public:
    cars(string am="",string amm="",string vt="",string mg=""){a_marke=am;a_modelis=amm;var_turis=vt;maks_grietis=mg;}
};
class Bclass:public cars{
public:
string get_marke(){return a_marke;}
string get_modelis(){return a_modelis;}
string get_var_turis(){return var_turis;}
string get_maks_grietis(){return maks_grietis;}
void set_mark(string a=""){a_marke=a;}
void set_modelis(string a=""){a_modelis=a;}
void set_ark(string s=""){var_turis=s;}
void set_mks_g(string s=""){maks_grietis=s;}
};
template<class cs>
class store{
public:
vector<cs>komandos;
store(){}
void operator + ( Bclass &c2) {
Bclass tmp =c2;
komandos.push_back(tmp);
}
};
template<class cs>
class out_u{
store<cs> lp;
public:
void startup(){
cout << "loading" << endl;
ifstream filein;
string str;
filein.open("db.txt");
int temp=0,temp2=0;
string a1,a2,a3,a4;
while(getline (filein, str))
{
if(temp==0)
{
a3=str;
}
if(temp==1)
{
a4=str;
}
if(temp==2)
{
a1=str;
}
if(temp==3)
{
a2=str;
}
temp++;
if(temp==4)
{
Bclass load_t;
load_t.set_mark(a3);
load_t.set_modelis(a4);
load_t.set_ark(a1);
load_t.set_mks_g(a2);
lp+load_t;
temp2++;
temp=0;
}
}        
for(int y=0; y!=temp2; y++)
{
cout<<"+";
}
cout<<endl;
cout<<"load: "<<temp2<<endl;
cout<<endl;
filein.close();
}
~out_u(){
int temp=0;
ofstream fileout;
fileout.open("db.txt", ios::out);
for(int o=0; o!=test_see(); o++)
{
fileout <<lp.komandos[o].get_marke()<<"\n";
fileout <<lp.komandos[o].get_modelis()<<"\n";
fileout <<lp.komandos[o].get_var_turis()<<"\n";
fileout <<lp.komandos[o].get_maks_grietis()<<"\n";
temp++;
cout<<"+";
}
fileout.close();
cout<<endl;
cout<<"save: "<<temp<<endl;
lp.komandos.clear();
}
int test_see(){
return lp.komandos.size();
}
};
int main()
{
out_u test;
test.startup();
cout<<"______"<<endl;
cout<<test.test_see();
return 0;
}

i get this error

||=== Build: Debug in 2nd_tadas (compiler: GNU GCC Compiler) ===|
D:\c++woėr\2nd_tadas\main.cpp||In function 'int main()':|
D:\c++woėr\2nd_tadas\main.cpp|145|error: missing template arguments before 'test'|
D:\c++woėr\2nd_tadas\main.cpp|146|error: 'test' was not declared in this scope|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Last edited on
Line 112:
out_u test;

You need to provide template arguments for this declaration.
This is needed because out_u needs to know what is the type of it's member store<cs> lp;

if it's int then do it like this:
out_u<int> test;
Last edited on
Topic archived. No new replies allowed.