dimanche 29 janvier 2017

Error request for member 'str' in 'c', which is of non-class type

this is the .hpp file for which i had written implementation still having errors please help me solve them thank you in advance.

#ifndef STORE_HPP

#define STORE_HPP

#include<string>

#include "Customer.hpp"

class Store

{

private:

std::vector<std::string> inventory;

std::vector<std::string> members;

public:

void addProduct(Product* p);

void addMember(Customer* c);

Product* getProductFromID(std::string);

Customer* getMemberFromID(std::string);

void productSearch(std::string str);

void addProductToMemberCart(std::string pID, std::string mID);

void checkOutMember(std::string mID);

};

#endif

this is the .cpp file some methods are having errors please solve them thankyou in advance

#include <iostream>
#include <string.h>
#include "Customer.hpp"
#include "Store.hpp"
#include "Product.hpp"
using namespace std;

string id;

void Store::addProduct(Product* p)
{
    Product p(std::string id, std::string t, std::string d, double p, int qa);
    inventory.push_back(id);
}
void Store:: addMember(Customer* c)
{
    Customer c(std::string n, std::string a, bool pm);
    members.push_back(c.str());
}

std::String Store:: Product* getProductFromID(std::string id)
{
    for(int i = 0; i < inventory.size(); i++)
    {
        Product* p=inventory.at(i);
        if(p->getProductFromID(id) == id)
        {
            return p;
        }
}
    return NULL;
}
std::String Store:: Customer* getMemberFromID(std::string id)
{
    for(int i = 0; i < members.size(); i++)
    {
        Customer* c = members.at(i);
        if(c->getAccountID() == id)
        {

            return c;
        }
    }
    return NULL;
}
void std::Store productSearch(std::string str)
{
    for(int i = 0; i < inventory.size(); i++)
    {
        if(inventory[i] == str)
        {
            Product stud(inventory[i],inventory[i+1],inventory[i+2],inventory[i+3],inventory[i+4]);
cout<<getIdCode();

cout<<getTitle();

cout<<getDescription();

cout<<getPrice();

cout<<getQuantityAvailable();
        }
    }
}
void addProductToMemberCart(std::string pID, std::string mID)
{
    cout<<"adding to cart"<<endl;
    getMemberFromID(mID)->addProductToCart(pID);  

}

void checkOutMember(std::string mID)
{
    Customer* c=getAccountID(mID)
    mID=getMemberFromID(std::string mID);
    if(mID=="NULL")
    {
        cout<<mID<<"is not found"<<endl;
    }

}

this is the customer.hpp file

#ifndef CUSTOMER_HPP

#define CUSTOMER_HPP

#include<vector>

#include "Product.hpp"

class Customer

{

private:

std::vector<std::string> cart;

std::string name;

std::string accountID;

bool premiumMember;

public:

Customer(std::string n, std::string a, bool pm);

std::string getAccountID();

//std::vector getCart();

void addProductToCart(std::string);

bool isPremiumMember();

void emptyCart();

};

#endif

this is the .cpp file for the customer

#include <iostream>
#include <string>

#include <vector>
#include "Customer.hpp"


using namespace std;




string accountID;

bool premiumMember;


Customer::Customer(std::string n, std::string a, bool pm)
{
    name=n;
    accountID=a;
    premiumMember=pm;   
}

std::string Customer:: getAccountID()
{
    return accountID;
}



void Customer:: addProductToCart(std::string accountID)
{

     cart.push_back(accountID);
}

bool Customer:: isPremiumMember()
{
    return premiumMember;
}
/*vector Customer::getCart()
{
    return std::cart;
}*/
void Customer:: emptyCart()
{
    cart.clear();
}

this is the product.hpp file

#ifndef PRODUCT_HPP

#define PRODUCT_HPP

#include<vector>

class Product

{

private:

std::string idCode;

std::string title;

std::string description;

double price;

int quantityAvailable;

public:

Product(std::string id, std::string t, std::string d, double p, int qa);

std::string getIdCode();

std::string getTitle();

std::string getDescription();

double getPrice();

int getQuantityAvailable();

void decreaseQuantity();

};

#endif

this is the .cpp file for product.hpp

#include<iostream>
#include<string>

#include "Product.hpp"


using namespace std;
string idCode;
string title;
string description;
double price;
int quantityAvailable;

Product::Product(std::string id, std::string t, std::string d, double p, int qa)
{
    idCode=id;
    title=t;
    description=d;
    price=p;
    quantityAvailable=qa;

}


std::string Product:: getIdCode()
{
    return idCode;

}
std::string Product::getTitle()
{
    return title;

}

std::string Product::getDescription()
{
    return description;

}

double Product::getPrice()
{
    return price;

}

int Product::getQuantityAvailable()
{
    return quantityAvailable;

}

Aucun commentaire:

Enregistrer un commentaire