How to correct a segmentation fault?
I keep getting an error Segmentation fault (core dumped), so I ran
valgrind. It is my first time using it, so not sure what to do to get my
code working. I've tried changing it, but it still says core dumped, or I
receive more errors than I had before. I did try debugging the code with
gdb, but the debugger was not working properly.
and corresponding product.h
#ifndef GS_PRODUCT
#define GS_PRODUCT
#include <iostream>
#include <string>
using namespace std;
class Product
{
private:
int plu_code;
string name;
double price;
bool by_weight;
double inventory;
public:
Product(int p_code = 0, string p_name = "", bool p_by_weight =
true, double p_price = 0.0, double p_inv = 0.0);
bool sold_by_weight(void);
double compute_cost(double weight_or_unit);
string get_name(void);
int get_plu_code(void);
double get_price(void);
double get_inventory(void);
};
No comments:
Post a Comment