Try this as an alternative, I was never partial to the C++ standard string class.
Code:
#include <iostream>
#include <string>
#define SIZE 100
using namespace std;
class bookmarks
{
private:
char url[SIZE];
char title[SIZE];
public:
bookmarks();
void setbookmarks(char *x, char *y); //how should I set?
void getbookmarks();
};
bookmarks::bookmarks()
{
memset(url, 0, SIZE); //how should I set initialize all elements to be null?
memset(title, 0, SIZE);
}
void bookmarks::setbookmarks(char *x, char *y)
{
strcpy(url, x); //how should I set?
strcpy(title, y);
}
void bookmarks::getbookmarks()
{
int i;
cout << " URL Page Title";
for (i = 0; i < SIZE; i++)
cout << url[i];
cout << " ";
cout << title[i];
cout << endl;
}
But, if you must use the string class, this will work
Code:
bookmarks::bookmarks()
{
url = "";
title = "";
}
void bookmarks::setbookmarks(string& x, string& y)
{
url = x;
title = y;
}
-Prelude