Hello!
I'm having a problem in trying to copy the content of a vector to another vector.
Essentially what I want is to create a vector of pointer
Alarm *vector[];
Alarm *vector[];
To copy to clipboard, switch view to plain text mode
and add them pointers that point to objects
for (...;...;...)
{
vector[] = new Alarm;
etc.
}
for (...;...;...)
{
vector[] = new Alarm;
etc.
}
To copy to clipboard, switch view to plain text mode
than I want to pass that vector to a different class through a function that will makes a different vector
Alarm *alarms[];
Alarm *alarms[];
To copy to clipboard, switch view to plain text mode
that will "copy" the content of the first, i.e. will point to the same objects of the first one in the same sequence. I though that I should do the following:
for (...;...;...)
{
alarms[] = vector[];
etc.
}
for (...;...;...)
{
alarms[] = vector[];
etc.
}
To copy to clipboard, switch view to plain text mode
but despite the compiler runs OK, when I try to use the software it crashes, displaying the message that the software stop working and I must close.
Notice, though, that this only happens when the copy is done in this second class. If the same copy is done in the original class, everything runs fine! So, what is the problem?
Details:
I'm calling the following method to do the copy:
v_alarmmanagment->readExistingAlarms(v_vector, numberofalarms);
/***************/
void AlarmManagment::readExistingAlarms(Alarm *alarms[], int numb)
{
vector2[numb] = alarms[numb];
}
v_alarmmanagment->readExistingAlarms(v_vector, numberofalarms);
/***************/
void AlarmManagment::readExistingAlarms(Alarm *alarms[], int numb)
{
vector2[numb] = alarms[numb];
}
To copy to clipboard, switch view to plain text mode
Thanks!
Momergil
-----
Edit: only now I saw that I should have posted this thread in the "General Programming" section. Sorry!
Bookmarks