Bonjour,

J'ai un problème avec le programme suivant:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <vector>
using namespace std;
 
class Vertex {
public:
	double x, y;
	Vertex(double a, double b)  {x=a; x=b;}
};
 
int main()
{
vector<Vertex> a;
a.resize(3);
}
qui donne le message d'erreur suivant:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
test.cpp: In member function ‘void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type, std::vector<_Tp, _Alloc>::value_type) [with _Tp = Vertex, _Alloc = std::allocator<Vertex>, std::vector<_Tp, _Alloc>::size_type = unsigned int, std::vector<_Tp, _Alloc>::value_type = Vertex]’:
test.cpp:15:11: erreur: no matching function for call to ‘Vertex::Vertex()’
test.cpp:15:11: note: candidates are:
test.cpp:8:2: note: Vertex::Vertex(double, double)
test.cpp:8:2: note:   candidate expects 2 arguments, 0 provided
test.cpp:5:7: note: Vertex::Vertex(const Vertex&)
test.cpp:5:7: note:   candidate expects 1 argument, 0 provided
[2]+  Fini                    eclipse test.cpp
Merci d'avance.