Okay great!
Almost everything works, I have no error in the formula, cons by something blocking the main ():
Code:
1. # include <vector>
2. # include <iostream>
3. # include <cmath>
4. # define G 6.67E-11
5. # define N 2
6. using namespace std;
7.
8.
9. struct Coordonnees
10. (
11. float x;
12. float y;
13. );
14.
15. struct body (
16. float mass;
17. Position coordinates;
18. Coordinates speed;
19. Acceleration coordinates;
20.
21. );
22.
23. Coordinates operator - (coordinates a, b Coordonnees)
24. (
25. Coordinates res;
26. res.x = ax-bx;
27. res.y = ay-by;
28. return res;
29. )
30.
31. float norm (vector Coordonnees)
32. (
33. float n = sqrt (pow (vecteur.x, 2) + pow (vecteur.y, 2));
34. return n;
35. )
36.
37.
38. calcul_acceleraton void (vector <body> tableau_de_corps)
39. (
40. * Coordinates = new tableau_de_acc Coordonnees [N];
41. int i = 0;
42. for (i, i <(N-1) i + +)
43. (
44. tableau_de_acc [i]. x = (tableau_de_corps [i +1]. mass) * (tableau_de_corps [i +1]. position.x);
45. tableau_de_acc [i]. x = (tableau_de_corps [i +1]. mass) * (tableau_de_corps [i +1]. position.x - tableau_de_corps [i]. position.x) / abs (pow (norm (tableau_de_corps [i] . tableau_de_corps-position [i +1]. position), 3));
46. tableau_de_acc [i]. y = (tableau_de_corps [i +1]. mass) * (tableau_de_corps [i +1]. position.y - tableau_de_corps [i]. position.y) / abs (pow (norm (tableau_de_corps [i] . tableau_de_corps-position [i +1]. position), 3));
47. court <<tableau_de_acc [i]. x <<endl;
48.
49. )
50. tableau_de_acc [i]. y *= G;
51. tableau_de_acc [i]. x *= G;
52. )
53.
54.
55.
56. int main ()
57. (
58. vector <corps*> liste_corps / / No creation of body
59. calcul_acceleraton (vector liste_corps) Missing template arguments before 'liste_corps'
60. return 0;61. )
Missing template arguments before 'liste_corps' on the line calling the function calcul_acceleration
Voila, thank you, I think (hope) that it will be the last question.
PS: I still have a second concern, I have tried to
Code:
1. liste_corps [1]. position.x = 1;
I put the following error:
Code:
1. error: request for member 'position' in 'liste_corps. std:: vector <_Tp, _Alloc>:: operator [] [with _Tp = body *, _Alloc = std:: allocator <corps*>] (1UL) 'Which is of non-class type' body * '
Bookmarks