Invalid use of incomplete type class Vertices (with templates)
I think I did everything correctly. I just can't understand whats the problem.
Heres my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
template<typename>
class Vertices;
template<typename T>
class Vertex {
void t() {
Vertices<int> vtcs;
vtcs.t();
//main.cpp:21:13: error: invalid use of incomplete type ‘class
//Vertices’
// vtcs.t();
// ^
}
};
template<typename T>
class Vertices {
public:
void t() {
}
};
| |
can someone help me with this? Thanks :).
Last edited on
At the point you try to use the function
t()
, the compiler needs to know about it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
template<typename T>
class Vertices {
public:
void t() {
}
};
template<typename T>
class Vertex {
void t() {
Vertices<int> vtcs;
vtcs.t();
}
};
| |
Thank you for your answer! But is there a way I can predeclare function something like this?
Vertices::void t();
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
template<typename T>
class Vertex {
public:
void t();
};
template<typename T>
class Vertices {
public:
void t() {
}
};
template<typename T>
void Vertex<T>::t(){
Vertices<int> vtcs;
vtcs.t();
}
| |
Topic archived. No new replies allowed.