Сначала я создаю окно, серию прямоугольников и помещаю их в вектор, а затем возникает проблема. Код не может быть построен. Но я не знаю почему. Разве что я не могу использовать вектор таким образом "прямоугольник вектора"
#include
#include
#include "Graph.h" // get access to our graphics library facilities
#include "Simple_window.h"
int main()
{
Graph_lib::Point tl{ 100, 100 };
Simple_window win{ tl, 1000, 800, "Simple Window" };
int x_size = 800;
int y_size = 800;
using namespace std;
vector rect;//error
for (int x = 0, y = 0; x < x_size&&y < y_size; x += x_grid, y += y_grid)
{
Graph_lib::Rectangle r(Graph_lib::Point(x, y), x_grid, y_grid);
r.set_fill_color(Graph_lib::Color::red);
rect.push_back(r);
}
for (int i = 0; i < 8; i++)
win.attach(rect[i]);
win.attach(grid);
win.wait_for_button();
return 0;
}
D:\Visual Studio Community 2017\VC\Tools\MSVC\14.11.25503\include\xmemory0(856): ошибка C2280: 'Graph_lib::Rectangle:: Rectangle(const Graph_lib::Rectangle &)': попытка сослаться на удаленную функцию
D:\VS_practice\ChengLu_C13Drill\include\Graph.h(311): note: compiler has generated 'Graph_lib::Rectangle::Rectangle' here
D:\Visual Studio Community 2017\VC\Tools\MSVC\14.11.25503\include\vector(958): note: see reference to function template instantiation 'void std::_Default_allocator_traits::construct(_Alloc &,_Objty *const ,const _Ty &)' being compiled
with
[
_Alloc=std::allocator,
_Ty=Graph_lib::Rectangle,
_Objty=Graph_lib::Rectangle
]
D:\Visual Studio Community 2017\VC\Tools\MSVC\14.11.25503\include\vector(958): note: see reference to function template instantiation 'void std::_Default_allocator_traits::construct(_Alloc &,_Objty *const ,const _Ty &)' being compiled
with
[
_Alloc=std::allocator,
_Ty=Graph_lib::Rectangle,
_Objty=Graph_lib::Rectangle
]
D:\Visual Studio Community 2017\VC\Tools\MSVC\14.11.25503\include\vector(981): note: see reference to function template instantiation 'void std::vector::emplace_back(const _Ty &)' being compiled
with
[
T=Graph_lib::Rectangle,
_Ty=Graph_lib::Rectangle
]
D:\Visual Studio Community 2017\VC\Tools\MSVC\14.11.25503\include\vector(980): note: while compiling class template member function 'void std::vector::push_back(const _Ty &)'
with
[
T=Graph_lib::Rectangle,
_Ty=Graph_lib::Rectangle
]
D:\VS_practice\ChengLu_C13Drill\src\main.cpp(32): note: see reference to function template instantiation 'void std::vector::push_back(const _Ty &)' being compiled
with
[
T=Graph_lib::Rectangle,
_Ty=Graph_lib::Rectangle
]
d:\vs_practice\chenglu_c13drill\include\std_lib_facilities.h(72): note: see reference to class template instantiation 'std::vector' being compiled
with
[
T=Graph_lib::Rectangle,
_Ty=Graph_lib::Rectangle
]
D:\VS_practice\ChengLu_C13Drill\src\main.cpp(27): note: see reference to class template instantiation 'Vector' being compiled
D:\VS_practice\ChengLu_C13Drill\include\Graph.h(311): note: 'Graph_lib::Rectangle::Rectangle(const Graph_lib::Rectangle &)': function was implicitly deleted because a base class invokes a deleted or inaccessible function 'Graph_lib::Shape::Shape(const Graph_lib::Shape &)'
D:\VS_practice\ChengLu_C13Drill\include\Graph.h(232): note: 'Graph_lib::Shape::Shape(const Graph_lib::Shape &)': function was explicitly deleted
Сначала я создаю окно, серию прямоугольников и помещаю их в вектор, а затем возникает проблема. Код не может быть построен. Но я не знаю почему. Разве что я не могу использовать вектор таким образом "прямоугольник вектора"
[code]#include #include #include "Graph.h" // get access to our graphics library facilities #include "Simple_window.h" int main() {
using namespace std; vector rect;//error for (int x = 0, y = 0; x < x_size&&y < y_size; x += x_grid, y += y_grid) { Graph_lib::Rectangle r(Graph_lib::Point(x, y), x_grid, y_grid); r.set_fill_color(Graph_lib::Color::red); rect.push_back(r); }
for (int i = 0; i < 8; i++) win.attach(rect[i]); win.attach(grid); win.wait_for_button();
return 0; } [/code]
D:\Visual Studio Community 2017\VC\Tools\MSVC\14.11.25503\include\xmemory0(856): ошибка C2280: 'Graph_lib::Rectangle:: Rectangle(const Graph_lib::Rectangle &)': попытка сослаться на удаленную функцию
[code]D:\VS_practice\ChengLu_C13Drill\include\Graph.h(311): note: compiler has generated 'Graph_lib::Rectangle::Rectangle' here
D:\Visual Studio Community 2017\VC\Tools\MSVC\14.11.25503\include\vector(958): note: see reference to function template instantiation 'void std::_Default_allocator_traits::construct(_Alloc &,_Objty *const ,const _Ty &)' being compiled with [ _Alloc=std::allocator, _Ty=Graph_lib::Rectangle, _Objty=Graph_lib::Rectangle ]
D:\Visual Studio Community 2017\VC\Tools\MSVC\14.11.25503\include\vector(958): note: see reference to function template instantiation 'void std::_Default_allocator_traits::construct(_Alloc &,_Objty *const ,const _Ty &)' being compiled with [ _Alloc=std::allocator, _Ty=Graph_lib::Rectangle, _Objty=Graph_lib::Rectangle ]
D:\Visual Studio Community 2017\VC\Tools\MSVC\14.11.25503\include\vector(981): note: see reference to function template instantiation 'void std::vector::emplace_back(const _Ty &)' being compiled with [ T=Graph_lib::Rectangle, _Ty=Graph_lib::Rectangle ]
D:\Visual Studio Community 2017\VC\Tools\MSVC\14.11.25503\include\vector(980): note: while compiling class template member function 'void std::vector::push_back(const _Ty &)' with [ T=Graph_lib::Rectangle, _Ty=Graph_lib::Rectangle ]
D:\VS_practice\ChengLu_C13Drill\src\main.cpp(32): note: see reference to function template instantiation 'void std::vector::push_back(const _Ty &)' being compiled with [ T=Graph_lib::Rectangle, _Ty=Graph_lib::Rectangle ]
d:\vs_practice\chenglu_c13drill\include\std_lib_facilities.h(72): note: see reference to class template instantiation 'std::vector' being compiled with [ T=Graph_lib::Rectangle, _Ty=Graph_lib::Rectangle ]
D:\VS_practice\ChengLu_C13Drill\src\main.cpp(27): note: see reference to class template instantiation 'Vector' being compiled
D:\VS_practice\ChengLu_C13Drill\include\Graph.h(311): note: 'Graph_lib::Rectangle::Rectangle(const Graph_lib::Rectangle &)': function was implicitly deleted because a base class invokes a deleted or inaccessible function 'Graph_lib::Shape::Shape(const Graph_lib::Shape &)'
D:\VS_practice\ChengLu_C13Drill\include\Graph.h(232): note: 'Graph_lib::Shape::Shape(const Graph_lib::Shape &)': function was explicitly deleted [/code]