Normal way to make a new object:
std::string date1 = "10/1/2010"; Date d1(stringToChar(date1);
But I can't figure out how to use that in a struct. The struct:
struct RecPayments
{
std::string name;
Date datemake();
float cost;
};
Trying to use it like this:
void addRecurring()
{
//New recurring payment
RecPayments * newPaymentItem = new RecPayments;
//Set recurring payment properties
newPaymentItem->name = "Test Payment";
newPaymentItem->datemake(stringToChar("4/12/2011"));
newPaymentItem->cost = 5;
}
Error received:
error: no matching function for call to ‘RecPayments::datemake(const char*)
What's the proper way to do this?
Well, the compiler is right. The way you've used the struct has given you (in effect) a class. You declared a function RecPayments::datemake()
but never defined it anywhere. What's more, you didn't even call this version of the function you created--you sent with it an argument that it didn't expect.
You need to remove the ()
in the datemake variable you've declared, or make a full function out of it. I'm not sure from the question which one you wanted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With