char* pointer

Dear all,

In my below code, I have this error msg saying : no instance of constructor matches the argument list.
Can anyone shed some light to this issue?
thanks!

class WeeklySales {
char* salesPerson;
double* amount;
int noOfWeek;

public:
WeeklySales(char *sp, double *a, int week)
{
salesPerson = sp;
amount = a;
noOfWeek = week;

}

void show()
{
cout << salesPerson << "\n " << amount << "\n" << noOfWeek;
}
};

int main()
{
WeeklySales ob("Sam", 50, 4); ---> the word sam cant be accepted as an arugment
ob.show();
return 0;
}
Couple of issues:

Use [code][/code] tags,
passing a string literal to a char pointer is supposedly deprecated, use std::string as opposed to char * (though char * still seems to work, it is still likely better to use std::string),
when you construct the object, you pass 50 (an int) to a parameter of type double *. Also, amount is a pointer to a double too, did you mean to make it just a double (an the parameter in your constructor too)?
Hi Danny,

Yes i am making it just a double.
Due to education purposes, i am only allowed to use char*.
You should use const char*, but that isn't the problem. The problem is the constructor takes a pointer to double as the second argument and you're feeding it an int literal. Chances are you don't actually want a pointer to double. Just use double as the data type for amount.
Hi cire,

thanks for the advice but i am unable to change the datatype to the weeklysales class.
Then change the type of the argument you're feeding to the constructor.
Topic archived. No new replies allowed.