Why is it that this throws a SIGSEGV signal when debugging?
Here is my .h file showing the declaration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#ifndef PAYMENT_H
#define PAYMENT_H
#include "Item.h"
#include <vector>
class Payment {
public:
Payment();
void ProcessItem();
private:
vector<Item*> items;
};
#endif /* PAYMENT_H */
|
Here is my driver class
1 2 3 4 5 6 7 8 9 10 11 12
|
#include "Payment.h"
using namespace std;
int main(int argc, char** argv)
{
Payment* myPayment;
myPayment->ProcessItem(/*Item that is irrelevant*/);
return 0;
}
|
And here is my Payment.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include "Payment.h"
#include "Item.h"
Payment::Payment()
{
this->items.clear();
}
void Payment::ProcessItem()
{
Item* myItem = new Item("Car", 99999.00);
this->items.push_back(myItem);
}
|
On line 13 in Payment.cpp the SIGSEGV signal is thrown and I cannot figure out why this is. I believe it has something to do with my vector declaration but it does not make any sense to me.
To be thorough, this is the content of the signal window that pops up:
===========================================================================
Signal received: SIGSEGV (?) with sigcode ? (?)
From process: ?
For program vector_test, pid -1
You may discard the signal or forward it and you may continue or pause the
process
To control which signals are caught or ignored use Debug->Dbx Configure
===========================================================================