Witam - nowy użytkownik.
Etap nauki - Vectory.
Zadanie : zdefiniować vector do przechowania 20 liczb naturalnych.
Mój kod:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
vector < int > tab( 20 );
}
.
Problem:
Kod sie nie kompiluje. Podczas kompilacji otwiera bibliotekę o nazwie "stl_vector.h" i ustawia tam na lini :
": public _Alloc { "
a
w kompliatorze dostaje log i 11 błedów :
Kompilator: Default compiler
Wykonywanie g++.exe...
g++.exe "D:\Programy C++\Vector.cpp" -o "D:\Programy C++\Vector.exe" -W -Wall -Weffc++ -Wfloat-equal -Werror -I"D:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"D:\Dev-Cpp\include\c++\3.4.2\backward" -I"D:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"D:\Dev-Cpp\include\c++\3.4.2" -I"D:\Dev-Cpp\include" -L"D:\Dev-Cpp\lib"
D:/Dev-Cpp/include/c++/3.4.2/bits/allocator.h: In instantiation of `std::allocator<int>':
D:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h:79: instantiated from `std::_Vector_base<int, std::allocator<int> >::_Vector_impl'
D:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h:110: instantiated from `std::_Vector_base<int, std::allocator<int> >'
D:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h:142: instantiated from `std::vector<int, std::allocator<int> >'
D:\Programy C++\Vector.cpp:9: instantiated from here
D:/Dev-Cpp/include/c++/3.4.2/bits/allocator.h:81: warning: base class `class __gnu_cxx::new_allocator<int>' has a non-virtual destructor
D:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h: In instantiation of `std::_Vector_base<int, std::allocator<int> >::_Vector_impl':
D:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h:110: instantiated from `std::_Vector_base<int, std::allocator<int> >'
D:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h:142: instantiated from `std::vector<int, std::allocator<int> >'
D:\Programy C++\Vector.cpp:9: instantiated from here
D:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h:79: warning: base class `class std::allocator<int>' has a non-virtual destructor
D:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h:79: warning: `struct std::_Vector_base<int, std::allocator<int> >::_Vector_impl' has pointer data members
D:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h:79: warning: but does not override `std::_Vector_base<int, std::allocator<int> >::_Vector_impl(const std::_Vector_base<int, std::allocator<int> >::_Vector_impl&)'
D:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h:79: warning: or `operator=(const std::_Vector_base<int, std::allocator<int> >::_Vector_impl&)'
D:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h: In instantiation of `std::vector<int, std::allocator<int> >':
D:\Programy C++\Vector.cpp:9: instantiated from here
D:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h:142: warning: base class `struct std::_Vector_base<int, std::allocator<int> >' has a non-virtual destructor
Wykonanie zakończone
I jeszcze takie zachowanie - jak definicję vectora zapiszę tak:
vector<int> tab():
to się kompiluje i nie ma żadnego błędu .
Może to nie dla mnie nauczyc sie tego języka :( .