|
|
main.cpp:60:19: warning: suggest parentheses around assignment used as truth value [-Wparentheses] if (Number = 1) |
if (Number = 1)
should be if (Number == 1)
.main.cpp:62:14: error: ‘Velocity’ was not declared in this scope a = (Velocity.at(Number+1)-Velocity.at(Number))/(Time.at(Number+1)- |
|
|
main.cpp:62:11: error: no match for ‘operator=’ (operand types are ‘std::vector<double>’ and ‘__gnu_cxx::__alloc_traits<std::allocator<double> >::value_type {aka double}’) a = (v.at(Number+1)-v.at(Number))/(t.at(Number+1)- |
a[Number] = (v.at(Number+1)-v.at(Number))/(t.at(Number+1)/(t.at(Number+1)-t.at(Number-1));
main.cpp:65:14: error: no match for ‘operator<<’ (operand types are ‘std::ostream {aka std::basic_ostream<char>}’ and ‘std::vector<double>’) cout << a << " " << p << endl; |
|
|
main.cpp: At global scope: main.cpp:85:1: error: expected unqualified-id before ‘{’ token |
|
|
main.cpp:65:14: error: no match for ‘operator<<’ (operand types are ‘std::ostream {aka std::basic_ostream<char>}’ and ‘std::vector<double>’) cout << a << " " << p << endl; Again, a is a std::vector<double>, you can't just throw it into an ostream like that. A clean way to do so:
|
F:\*.cpp|19|error: invalid use of template-name 'std::ostream_iterator' without an argument list| F:\*.cpp|20|error: expected constructor, destructor, or type conversion before '(' token| |
std::ostream_iterator
is a template class and you must supply the type of the variable you are inserting into the stream when you define a std::ostream_iterator
.std::ostream_iterator<double> ostr_it(std::cout, " ") ;
Time(Sec) ---Velocity (m/s) 0 ---0 0.1 ---0 0.2 ---0 0.3 ---0.016532735 0.4 ---0.091686478 0.5 ---0.391340578 0.6 ---1.014768606 0.7 ---2.196126032 0.8 ---3.871247372 0.9 --5.789352979 1 ---7.716825525 1.1 ---9.490237052 1.2 ---11.3509455 1.3 ---13.21353105 |
Number TIME Velocity 1 0 0 terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Process returned 3 (0x3) execution time : 1.732 s Press any key to continue. |
for (Number=1;Number<=t.size();Number++)
for (Number=0;Number<=t.size();Number++)
for (Number=0;Number<t.size();Number++)
at(Number+1)
|
|
|
|
if (Number = 1)
not to be assignment in calculateAccelerationArray
(line 60 in the OP - also mentioned by NwN.) If so, please pay attention to the warnings generated by your compiler. If there aren't any, turn your warning levels up.Number = t.size()+1;
. This doesn't actually affect your code except for the output on line 5 in the same code, since Number
is assigned a new value before it is used in calculateAccelerationArray
.
# gdb ./program gdb> catch throw gdb> run |