I am having an issue where every spot where I make a function call, such as item.GetName(), on an item in the vector<ItemToPurchase> items , I get the error message: no matching function for call to vector<ItemToPurchase,__default_alloc_template<false,0> >::at (int &) I've been looking all over and don't even uderstand what the "no matching function for call to" even means.
Example g++ message
ShoppingCart.cpp: In method `bool ShoppingCart::CheckCartForItem(class
string)':
ShoppingCart.cpp:22: no matching function for call to
`vector<ItemToPurchase,__default_alloc_template<false,0> >::at (int &)'
ShoppingCart.h:
#ifndef SHOPPINGCART_H
#define SHOPPINGCART_H
#include "ItemToPurchase.h"
#include <vector>
class ShoppingCart
{
public:
ShoppingCart(string customerName = "none", string dateCreated = "January 1, 2016");
*other functions*
bool CheckCartForItem(string itemName);
void AddItemToCart(ItemToPurchase item);
*more functions*
private:
*other variables*
std::vector<ItemToPurchase> items;
};
#endif
ShoppingCart.cpp
#include "ShoppingCart.h"
#include <iostream>
ShoppingCart::ShoppingCart(string customerName, string dateCreated)
{
this->customerName = customerName;
this->dateCreated = dateCreated;
}
bool ShoppingCart::CheckCartForItem(string itemName)
{
if (items.size() == 0) //if cart is empty
return false;
for (int i = 0; i < items.size(); i++)
{
if (items.at(i).GetName() == itemName) //<- Problem here
return true;
}
return false;
}
void ShoppingCart::AddItemToCart(ItemToPurchase item)
{
if (CheckCartForItem(item.GetName()) == false) //if item not in cart
items.push_back(item);
else
cout << "Item is already in cart. Nothing added." << endl;
}
ItemToPurchase.h
#ifndef ITEMTOPURCHASE_H
#define ITEMTOPURCHASE_H
#include <string>
using namespace std;
class ItemToPurchase
{
public:
ItemToPurchase(string name = "none", string description = "none", double
price = 0.0, int quantity = 0);
void SetName(string);
string GetName();
*other functions*
private:
string itemName;
*other variables*
};
#endif // ITEMTOPURCHASE_H
ItemToPurchase.cpp
#include "ItemToPurchase.h"
#include <iostream>
#include <iomanip>
ItemToPurchase::ItemToPurchase(string name, string description, double
price, int quantity)
{
itemName = name;
itemDescription = description;
itemPrice = price;
itemQuantity = quantity;
}
void ItemToPurchase::SetName(string name){ itemName = name; }
string ItemToPurchase::GetName() { return itemName; }
Since in this case you don't use the index variable, you can iterate with a range-based for loop:
for (auto& item : items) {
if (item.GetName() == itemName) {
[...]
std::vector:at expects a std::vector::size_type (which is typically defined as std::size_t). Changing the type of i should make it compatible when using the index-based accessor:
for (std::vector<ItemToPurchase>::size_type i = 0; i < items.size(); ++i) {
if (items.at(i).GetName() == itemName) {
[...]
Related
This question already has answers here:
vector of class without default constructor
(3 answers)
Object array initialization without default constructor
(14 answers)
C++ compiler complaining about no default constructor
(1 answer)
Closed 2 years ago.
As I currently study Java in University but I am working on a C++ project. It is a text game in which I'm trying to create an empty vector of Item objects which I'm later going to add with the addItem(Item newItem) method of the Room object. The problem is that when in the constructor I try to set it so that every time a room is created, a new vector of Item objects is created with a capacity of the vector of 20, it gives me this error:
'Item::Item': no appropriate default constructor available
Here is the code:
Item.hpp:
#include <iostream>
#include <string>
#ifndef Item_HPP
#define Item_HPP
class Item {
std::string description;
public:
Item(std::string description);
std::string getDescription();
void setDescription(std::string description);
void use();
};
#endif
Item.cpp:
#include "Item.hpp"
Item::Item(std::string description) {
this->description = description;
}
std::string Item::getDescription() {
return this->description;
}
void Item::setDescription(std::string description) {
this->description = description;
}
void Item::use() {
std::cout << "You are using item: " << description << std::endl;
}
Room.hpp:
#include <iostream>
#include <string>
#include <vector>
#include "Item.hpp"
#ifndef Room_HPP
#define Room_HPP
class Room {
std::string description;
static const int MAX_ITEMS = 20;
std::vector <Item> items;
int numberOfItems;
public:
Room(std::string description);
std::string getDescription();
void addItem(Item newItem);
std::vector<Item> getItems();
Item getItem(std::string description);
};
#endif
Room.cpp:
#include "Room.hpp"
Room::Room(std::string description) {
this->description = description;
this->items = std::vector<Item>(20);
this->numberOfItems = 0;
}
std::string Room::getDescription() {
return this->description;
}
void Room::addItem(Item newItem) {
if (numberOfItems < MAX_ITEMS) {
this->items[numberOfItems] = newItem;
numberOfItems++;
}
}
std::vector<Item> Room::getItems() {
return this->items;
}
Item Room::getItem(std::string description) {
int i = 0;
bool found = false;
Item *target = NULL;
while (!found && i < numberOfItems) {
if (items[i].getDescription() == description) {
target = &items[i];
found = true;
}
++i;
}
return *target;
}
You can firstly just reserve() buffer for 20 elements and later add elements via push_back().
Room::Room(std::string description) {
this->description = description;
this->items = std::vector<Item>();
this->items.reserve(20);
this->numberOfItems = 0;
}
void Room::addItem(Item newItem) {
if (numberOfItems < MAX_ITEMS) {
if (numberOfItems == static_cast<int>(this->items.size())) {
this->items.push_back(newItem);
} else if (numberOfItems < static_cast<int>(this->items.size())) {
this->items[numberOfItems] = newItem;
} else {
// unsupported to create gap between items
}
numberOfItems++;
}
}
I need to sort a vector of pointers with this test data.
main.cpp
#include "cart.h"
int main()
{
Cart cart;
cart.addItem("Desktop", 125.34f);
cart.addItem("Iphone", 46.274f);
cart.addItem("Pen", 118.99f);
cart.addItem("Ruler", 41.34f);
cart.addItem("Printer", 2.99f);
cart.printSortedItems();
cart.destroy();
}
item.h
#include <string>
#include <tuple>
class Item
{
private:
Item(const std::string& name, const ItemType& itemType, const float& price);
~Item();
std::string m_name;
float m_price;
public:
static Item *getInstance(const std::string& name, const float& price);
bool operator>(const Item& item2) const;
void print() const;
};
item.cpp
#include "item.h"
#include <iostream>
Item::Item(const std::string& name, const float& price)
{
m_name = name;
m_price = price;
}
Item::~Item()
{
}
Item *Item::getInstance(const std::string& name, const float& price)
{
return new Item(name, price);
}
bool Item::operator>(const Item & item2) const
{
if (m_name > item2.m_name) {
return true;
}
if (m_name == item2.m_name && m_price > item2.m_price) {
return true;
}
return false;
}
void Item::print() const
{
std::cout << "Item name: " << m_name << " Item price: "<< m_price << std::endl;
}
cart.h
#include <vector>
class Cart
{
public:
Cart();
~Cart();
void addItem(const std::string& name, const float& price);
void printSortedItems();
void sortItems();
void destroy();
private:
std::vector<Item*> m_itemList = {};
};
cart.cpp
#include "cart.h"
#include <iostream>
#include <algorithm>
Cart::Cart(){}
Cart::~Cart(){}
void Cart::addItem(const std::string& name, const float& price)
{
Item *newItem = Item::getInstance(name, itemType, price);
m_itemList.push_back(newItem);
}
void Cart::sortItems()
{
for (size_t i = 0; i < m_itemList.size()-1; i++)
{
for (size_t j = i + 1; j < m_itemList.size(); j++)
{
if (m_itemList[i] > m_itemList[j])
{
std::swap(m_itemList[i], m_itemList[j]);
}
}
}
}
void Cart::printSortedItems()
{
sortItems();
std::cout << "Items" << std::endl;
for (size_t i = 0; i < m_itemList.size(); i++)
{
m_itemList[i]->print();
}
std::cout << std::endl;
}
void Cart::destroy()
{
for (size_t i = 0; i < m_itemList.size(); i++)
{
delete m_itemList[i];
m_itemList[i] = nullptr;
}
}
In function Cart::sortItems(), I compare m_itemList[i] and m_itemList[j], these are both pointers to instance of Item. Theoretically, if I set a break point in bool Item::operator>(const Item & item2) const, it should be hit. But in this case, the break point is not hit, and therefore, the result after sorting is wrong. Could you guys tell me where I am wrong?
What I am trying to do is add cards to a vector that is to be a Blackjack hand, but each time I enter the function that uses push_back to add a card to the vector, the vector starts out empty. The problem is in my Hand class in the addCardToHand function, and the same issue is present in the same class in my showHand function. I have whittled the code down as much as I could but still present a full working version with the issue. I cannot figure out why my Hand class treats the hand as brand new every time I call a function in the class. Please advise.
// Card.h
#ifndef CARD_H
#define CARD_H
#include <string>
#include <array>
class Card {
private:
int rank;
int suit;
int hardValue;
int softValue;
static const std::array<std::string,14> ranks;
static const std::array<std::string,5> suits;
public:
Card();
Card(int rank, int suit);
int getHardValue() const;
int getSoftValue() const;
std::string toString() const;
};
#endif
// Card.cpp
#include "Card.h"
const std::array<std::string,14> Card::ranks {"","A","2","3","4","5","6","7","8","9","10","J","Q","K"};
const std::array<std::string,5> Card::suits {"","C","D","H","S"};
Card::Card() : rank(0), suit(0) {
hardValue = 0;
softValue = 0;
}
Card::Card(int rank, int suit) : rank(rank), suit(suit) {
if (rank == 1) {
hardValue = 1;
softValue = 11;
}
else if (rank <= 10) {
hardValue = rank;
softValue = rank;
}
else {
hardValue = 10;
softValue = 10;
}
}
int Card::getHardValue() const {
return hardValue;
}
int Card::getSoftValue() const {
return softValue;
}
std::string Card::toString() const {
return ranks[rank] + suits[suit];
}
// Shoe.h
#ifndef SHOE_H
#define SHOE_H
#include <vector>
#include <random>
#include "Card.h"
class Shoe {
private:
int numDecksInShoe;
std::vector<Card> shoe;
static int currentCard;
static int maxDealCard;
static const unsigned long int seed;
static std::mt19937 randEng;
void renewShoe();
public:
Shoe();
explicit Shoe(int numDecksInShoe);
std::vector<Card> getShoe() const;
int getCurrentCard() const;
int getMaxDealCard() const;
void shuffle();
Card dealCard();
};
#endif
// Shoe.cpp
#include <ctime>
#include "Shoe.h"
const unsigned long int Shoe::seed = static_cast<unsigned long int>(std::time(nullptr));
std::mt19937 Shoe::randEng(seed);
int Shoe::currentCard = 0;
int Shoe::maxDealCard = 51;
Shoe::Shoe() {
}
Shoe::Shoe(int decksInShoe) {
numDecksInShoe = decksInShoe;
int count = 0;
for (int i = 0; i < numDecksInShoe; i++) {
for (int suit = 4; suit >= 1; suit--) {
for (int rank = 1; rank <= 13; rank++) {
Card card(rank,suit);
shoe.push_back(card);
count += 1;
}
}
}
currentCard = 0;
maxDealCard = count - 1;
}
std::vector<Card> Shoe::getShoe() const {
return shoe;
}
int Shoe::getCurrentCard() const {
return currentCard;
}
int Shoe::getMaxDealCard() const {
return maxDealCard;
}
void Shoe::shuffle() {
Card temp;
std::uniform_int_distribution<int> deckDist(0,numDecksInShoe*52-1);
int index;
for (int i = 0; i < numDecksInShoe*52; i++) {
do {
index = deckDist(randEng);
} while (index == i);
temp = shoe[index];
shoe[index] = shoe[i];
shoe[i] = temp;
}
std::uniform_int_distribution<int> maxDeal(10,41);
int tempMax = (numDecksInShoe-1)*52 - 1;
maxDealCard = tempMax + 51 - maxDeal(randEng);
}
Card Shoe::dealCard() {
if (currentCard == maxDealCard) {
renewShoe();
}
Card dealCard = shoe[currentCard];
currentCard += 1;
return dealCard;
}
void Shoe::renewShoe() {
Shoe newShoe(numDecksInShoe);
shoe = newShoe.getShoe();
shuffle();
}
here is my Hand class
// Hand.h
#ifndef HAND_H
#define HAND_H
#include <vector>
#include <string>
#include "Card.h"
class Hand {
private:
std::vector<Card> hand;
public:
Hand();
std::vector<Card> getHand() const;
void addCardToHand(Card card);
void clearHand();
Card revealBottomCard();
std::string showHand() const;
std::string peakHand() const;
};
#endif
// Hand.cpp
#include <iostream>
#include "Hand.h"
Hand::Hand() {
}
std::vector<Card> Hand::getHand() const {
return hand;
}
void Hand::addCardToHand(Card card) {
std::cout << card.toString() << std::endl;
hand.push_back(card);
}
void Hand::clearHand() {
hand.clear();
}
std::string Hand::showHand() const {
std::string returnString = "";
for (int i = hand.size()-1; i >= 1; i--) {
returnString += hand[i].toString() + "\n";
}
returnString += "XX\n";
return returnString;
}
std::string Hand::peakHand() const {
std::string returnString = "";
for (int i = hand.size()-1; i >= 0; i--) {
returnString += hand[i].toString() + "\n";
}
return returnString;
}
here is the Table class that has the code that calls the Hand class functions
// Table.h
#ifndef TABLE_H
#define TABLE_H
#include "Shoe.h"
#include "Player.h"
class Table {
private:
Shoe shoe;
public:
explicit Table(Shoe shoe);
Shoe getShoe() const;
void clearHand(std::vector<Player> players);
void dealHand(std::vector<Player> players);
};
#endif
// Table.cpp
#include <iostream>
#include "Table.h"
Table::Table(Shoe shoe) : shoe(shoe) {
}
Shoe Table::getShoe() const {
return shoe;
}
void Table::clearHand(std::vector<Player> players) {
for (Player &player : players) {
player.getHand().clearHand();
}
}
void Table::dealHand(std::vector<Player> players) {
for (int i = 0; i <= 1; i++) {
for (Player &player : players) {
player.getHand().addCardToHand(shoe.dealCard());
}
}
}
// Player.h
#ifndef PLAYER_H
#define PLAYER_H
#include "Hand.h"
class Player {
private:
std::string name;
Hand hand;
double money;
public:
explicit Player(std::string name, double money = 1000.0);
std::string getName() const;
Hand getHand() const;
double getMoney() const;
};
#endif
// Player.cpp
#include "Player.h"
Player::Player(std::string name, double money) : name(name), money(money) {
}
std::string Player::getName() const {
return name;
}
Hand Player::getHand() const {
return hand;
}
double Player::getMoney() const {
return money;
}
and finally here is a short driver that runs and displays the issue
// blackjack testing
#include <iostream>
#include "Player.h"
#include "Table.h"
int main() {
std::vector<Player> players {Player("Tom",1500.0),Player("Sue"),Player("Dave")};
Shoe shoe1(6);
Table table1(shoe1);
table1.dealHand(players);
for (Player player : players) {
std::cout << player.getName() << "'s hand\n";
std::cout << player.getHand().showHand() << "\n\n";
}
}
The output is below. I printed out the cards that were added to the hand vector (and then 'forgotten') and below that above the XX's, if everything were to work correctly you should see the 4, 5 and 6 of spades since I did not shuffle the deck. The XX's are to simulate face down bottom card.
AS
2S
3S
4S
5S
6S
Tom's hand
XX
Sue's hand
XX
Dave's hand
XX
Sorry for dumping all this code in here, but I wanted to provide a full working solution and this is as small as I could get it. Thanks for any help.
player.getHand().addCardToHand(...);
player.getHand() returns a temporary Hand object that's a copy of player.hand. Then you add a card to that temporary object. Then that temporary object dies, added card and all. player.hand remains unchanged. This line of code is an elaborate no-op.
To add on #Igor's answer, the best way to fix this should probably return a reference instead:
const Hand& Player::getHand() const {
return hand;
}
I made this a const because returning a non-const could (potentially) allow you to break constness of a constant Player object. That is just inviting potential bugs.
Because of this, you may want to add a non-const version too:
Hand& Player::getHand() {
return hand;
}
Now you can't modify a const Player object, yet modify it properly when you need to.
So made a class called ‘Item’, and the object of that class will have a 100% condition at the start, the Player stores items (with name “apple” in this case) whenever I tell him to. In the degradeT function I want to pass the whole vector containing the items that the player has picked up by far and then change the condition of each Item in that vector by -1 through the chCond function.
first error:
initial value of reference to non-const must be an lvalue
second error:
'void degradeT(std::vector<Item,std::allocator<_Ty>> &)': cannot convert argument 1 from 'std::vector<Item,std::allocator<_Ty>>' to 'std::vector<Item,std::allocator<_Ty>> &'
#include "pch.h"
#include <iostream>
#include <string>
#include <vector>
using std::cout; using std::cin; using std::endl;
using std::string; using std::vector; using std::to_string;
class Item {
private:
string name; // Item name
float condition; // Item condition
bool consumable; // Is the item consumable
public:
Item() {}
Item(string a, float b, bool c) { name = a; condition = b; consumable = c; }
Item(string a, bool c) { name = a; condition = 100.f; consumable = c; }
string getName() {
return name;
}
float getCond() {
return condition;
}
bool isCons() {
return consumable;
}
void chCond(float a) { // Change Item condition
condition += a;
}
};
//-----------------------
class Player {
private:
vector<Item> plItems; // Item container
public:
Player() {}
void pickUpItem(Item a) { // Adding Items to inventory
plItems.push_back(a);
cout << a.getName() << " added to inventory!\n";
}
void checkItemConds() { // Checking condition of all items
for (unsigned int a = 0, siz = plItems.size(); a < siz; a++) {
cout << plItems[a].getName() << "'s condition is: " << plItems[a].getCond() << "%\n";
}
}
Item returnItem(unsigned int a) { // Return a specific Item
return plItems[a];
}
int getCurInvOcc() { // Get cuurent inventory occupation
return plItems.size();
}
vector<Item> getPlItems() { // Return the vector (Item container)
return plItems;
}
};
//-------------------------
void degradeT(vector<Item>& Itemss); // Degrade item after some time
//-------------------------
int main()
{
Player me; // me
string inp; // input
int num = 1; // apple 1, apple 2, apple 3...
while (inp != "exit") {
cin >> inp;
if (inp == "addApple") {
Item apple(("apple " + to_string(num)), true);
me.pickUpItem(apple);
num++;
}
if (inp == "checkItemConds") {
me.checkItemConds();
}
if (inp == "timeTick") {
// This doesn't have anything to do with time I just want to test the function manually
degradeT(me.getPlItems());
}
}
system("PAUSE");
return 0;
}
void degradeT(vector<Item> &Itemss) {
for (unsigned int a = 0, siz = Itemss.size(); a < siz; a++) {
Itemss[a].chCond(-1);
cout << Itemss[a].getName() << endl;
}
}
I'm not sure what your question is, but your error is related to the function void degradeT(vector<Item> & Itemss).
This functions expects a reference but you are passing an r-value. You can either return a reference with getPlItems() or pass an l-value to degradeT.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
i am new to c++ and i am currently trying to write a program that uses main to call functions which are seperately written and i tried to write the definitions for the header file declarations and i am getting errors with some functions which i have marked in the code
Store.hpp
#ifndef STORE_HPP
#define STORE_HPP
class Product;
class Customer;
#include<string>
#include "Customer.hpp"
#include "Product.hpp"
class Store
{
private:
std::vector<Product*> inventory;
std::vector<Customer*> 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
i am having trouble writing the code for that function help me
store.cpp
#include <iostream>
#include <string.h>
#include "Customer.hpp"
#include "Store.hpp"
#include "Product.hpp"
using namespace std;
string id;
void Store::addProduct(Product* p) //error 1 no matching function
{
Product* p(std::string id, std::string t, std::string d, double p, int qa);
inventory.push_back(p);
}
void Store:: addMember(Customer* c)
{
members.push_back(c->getAccountID());
}
Product* Store::getProductFromID(std::string id)
{
for(int i = 0; i < inventory.size(); i++)
{
Product* p=inventory.at(i);
if(p->getIdCode()= id)
{
return p;
}
}
return NULL;
}
Customer* Store:: 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;
}
}
customer.hpp
#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
product.hpp
#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
You code issues lots of warnings and errors as stands.
If you find yourself in this situation and can't figure out what one of them means, try to fix some of the others.
Your main problem is in addProduct, but there are others
using namespace std;
string id; //<---- what's this for?
void Store::addProduct(Product* p) //error 1 no matching function
{
//Product* p(std::string id, std::string t, std::string d, double p, int qa);
//<--- This line had the error and isn't needed
inventory.push_back(p);
}
void Store::addMember(Customer* c)
{
// members.push_back(c->getAccountID()); //<--- this errors too
members.push_back(c);
}
Product* Store::getProductFromID(std::string id)
{
for (size_t i = 0; i < inventory.size(); i++)
{
Product* p = inventory.at(i);
//if (p->getIdCode() = id) //<-- be careful with = and ==
if (p->getIdCode() == id) //<---
{
return p;
}
}
return NULL;
}
Customer* Store::getMemberFromID(std::string id)
{
for (size_t 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)
void Store::productSearch(std::string str) // <---- note this change too
{
for (size_t i = 0; i < inventory.size(); i++)
{
//if (inventory[i] == str) //<<--------!
if (inventory[i]->getDescription() == str)
{
//Product stud(inventory[i], inventory[i + 1], inventory[i + 2], inventory[i + 3], inventory[i + 4]);
// This is five Products from the inventory, not the i-th product in your invetory
Product stud(*inventory[i]);//<---- I assume
cout << stud.getIdCode();
cout << stud.getTitle();
cout << stud.getDescription();
cout << stud.getPrice();
cout << stud.getQuantityAvailable();
}
}
}
void Store::addProductToMemberCart(std::string pID, std::string mID)//<--- note note std::Store addProductToMemberCart
{
cout << "adding to cart" << endl;
getMemberFromID(mID)->addProductToCart(pID);
}
void Store::checkOutMember(std::string mID)//<---
{
//Customer* c = getAccountID(mID);//<<---?
//mID = getMemberFromID(std::string mID); //<---?
Customer* c = getMemberFromID(mID); //Just this?
if (c == NULL)//<---rather than "NULL" but nullptr might be better
{ // or not using pointers at all
cout << mID << "is not found" << endl;
}
}