Chcę w kilku funkcjach korzystać z tych samych zmiennych (na razie lokalnych) a nie mogę ich zadeklarować jako zmienne globalne :
'l_dvds' : global or static variable may not have managed type 'ZedGraph::PointPairList ^' may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
są zadeklarowane jako lokalne (działają):
PointPairList ^l_dvds = gcnew PointPairList();
PointPairList ^l_n_avg = gcnew PointPairList();
PointPairList ^l_w_zam = gcnew PointPairList();
PointPairList ^l_w_netto = gcnew PointPairList();
PointPairList ^l_zam = gcnew PointPairList();
PointPairList ^l_n_sum = gcnew PointPairList();
Zamiast deklarowac je jako globalne, utworzyłem klasę:
(...)
using namespace ZedGraph; //biblioteka do tworzenia wykresów, PointPairList jest klasą z ZedGraph
(...)
public ref class ppl
{
public:
PointPairList ^l_dvds;
PointPairList ^l_n_avg;
PointPairList ^l_w_zam ;
PointPairList ^l_w_netto ;
PointPairList ^l_zam ;
PointPairList ^l_n_sum ;
public: ppl(void)
{
l_dvds = gcnew PointPairList();
l_n_avg = gcnew PointPairList();
l_w_zam = gcnew PointPairList();
l_w_netto = gcnew PointPairList();
l_zam = gcnew PointPairList();
l_n_sum = gcnew PointPairList();
}
};
Do tego etapu się kompiluje. Kiedy próbuję stworzyć obiekt tej klasy:
ppl obiekt = gcnew ppl();
Otrzymuję następujące błędy:
1>.\core.cpp(59) : error C3145: 'obiekt' : global or static variable may not have managed type 'ppl' may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
1>.\core.cpp(59) : error C3673: 'ppl' : class does not have a copy-constructor
Jak sobie z tym poradzić, jak powinien wyglądać ten copy-constructor w tym przypadku?
proszę o pomoc i wyrozumiałość - dopiero zaczynam zabawę z obiektówką;/