I am trying to call the method ip_uri from class into the main but it does let me what am i doing wrong?
#include <iostream>
#include <string>
using namespace std;
class ip_uri_store
{
public:
string count; // C++ string s are classes so this is aggregation.
int id ; // Such strings are more powerful and easier to use
ip_uri_store *next;
string ip_uri(string ip50, string uri50);
protected:
string ip50;
string uri50;
};
ip_uri_store *list_head ; // Start of linked list, set to 1st item.
ip_uri_store *work_ptr;
string ip_uri_store::ip_uri(string ip50, string uri50)
{
if(ip50=="74.125.19.1")
uri50="www.google.com";
cout<<uri50<<endl;
return(uri50);
};
int main(int argc, char *argv[])
{
list_head = NULL;
int i = 0 ;
while ( i < argc )
{ work_ptr = list_head ; // save old head item.
list_head = new ip_uri_store; // create new item.
list_head->next = work_ptr ; // get next item to point to previous
list_head->count = argv[i] ;
list_head->id = i ; // fill in payload data.
i++ ;
}
work_ptr = list_head ; // point to start of list.
while( work_ptr != NULL) // not at end.
{ cout << " " << work_ptr->id << " " << work_ptr->count<< endl ;
work_ptr = work_ptr->next ; // point to next item in list, or NULL.
}
char ch;
for (int k = 1; k < 2; ++k) {
for (int j = 0; argv[k][j] != '\0'; ++j) {
ch = argv[k][j];
}
}
cout<<ch<<endl;
if(ch=='U')
{
string ip50=argv[2];
ip_uri_store google;
google.ip_uri(ip50);
}
return(0);
}