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?
The braces
()in yourDate datemake();are confusing the compiler.Just remove them.
If you want to explicitly create the
Dateobject insideaddRecurring()with non default c’tor then make it a pointer and create it..obviously as you use
new, you’ll now needdeletesomewhere as well.. or use smart pointers..