I am trying to learn pointers and I get this error. Do I need to change the header file class Request? Why am I getting such an error?
cannot convert `req' from type `Request' to type `Request *'
The error is happening in theses lines:
//Store necessary information in a Request object for each request.
Request req(url, request, 1);
Request *reqq = req; //req points to the object
list->Append(reqq);
code:
void
ClientThread(int request)
{
const int sz = 50;
char url[sz];
FILE *fp = fopen("url.txt", "r");
if (!fp)
printf(" Cannot open file url.txt!\n");
else {
int pos = 0;
char c = getc(fp);
while (c != EOF || pos == sz - 1) {
if (c == '\n') {
url[pos] = '\0';
serve(url);
pos = 0;
//Store necessary information in a Request object for each request.
Request req(url, request, 1);
Request *reqq = req; //req points to the object
list->Append(reqq);
}
else {
url[pos++] = c;
}
c = getc(fp);
}
fclose(fp);
}
}
my request.h file consist of the following:
class Request
{
public:
//constructor intializes request type
Request(char *u, int rqtID, int rqtrID);
char *url;
int requestID;
int requesterID;
}