Check for missing braces and semicolons:
1 2 3
|
void CacheType::displayPages() // <== Oops!
cout << pageURL << byteSize << mimeType << dateAcc;
}
| |
1 2 3 4 5 6 7 8
|
void CacheType::enterPage(string pageURL, int byteSize, string mimeType, string dateAcc)
{
cout << "Please enter the information associated with the page." << endl;
cout << " " << endl;
cout << "Page URL: " // <== Oops!
cin >> pageURL;
// ...
}
| |
Declare return type for functions that return sth. Declare variables that are used in member functions - you can pass them as arguments, declare them as class fields, or declare as local variables, but in function below you do none of these:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
void CacheType::searchPages()
{
cout << "Enter the URL of the webpage to search for: " << endl;
cin >> string pageURL; // <== what is 'string pageURL' ?
// Should it be just URL, a class member string?
int i= 0;
int result= -1;
while ((result= -1) && (i < size)){ // <= 'result = -1' or 'result == -1' ?
if (pageArray[i] == pageURL) // Also, what is size? A class member?
result= i; // What is pageArray[i]? Also a class member?
else
i ++;
}
return result;
}
| |
Should all these variables be class members? They are not in class declaration in header file:
1 2 3 4
|
void CacheType::displayPages()
{
cout << pageURL << byteSize << mimeType << dateAcc;
}
| |
All these methods must be found in class declaration (header file). If you change return type or argument list in one place - don't forget to update the other!
1 2 3 4 5
|
void CacheType::enterPage(string pageURL, int byteSize, string mimeType, string dateAcc);
void CacheType::displayPages();
void CacheType::searchPages(); // <== Oops! I'm not in header file!
bool CacheType::compare(CacheType newURL);// <== I am in implementation
bool compare (CacheType X, CacheType Y); // <== and I am in header. We are different functions!
| |
Pay attention to letter capitalization:
1 2 3 4 5
|
void sortPages(CacheType pageArray[], int size){
int temp;
int passCount;
CacheType searchIndex;
cacheType miniIndex; // <== Oops! No such type.
| |
This fragment of main has several mistakes:
1 2 3 4 5 6 7 8 9 10 11 12
|
CacheType searchIndex; // searchIndex is CacheType...
for (passCount =0; passCount < size - 1; passCount++){
miniIndex = passCount;
// ... but in the next line you try to assign it a value of int with '='.
// Then you compare it with another int with '<'
// And increment with '++'
// Did you plan to overload these operators?
// Or (more likely) is searchIndex supposed to be an int?
for (searchIndex = passCount +1; searchIndex < size; searchIndex++){
// Bool int? More like Bull Sh*t : http://instantrimshot.com/index.php?sound=rimshot :]
bool int compInd = pageArray[searchIndex].compare(pageArray[miniIndex]);x]
| |
Look out for single and double quotes, and again, don't mix data types:
1 2 3 4 5 6 7 8 9 10 11
|
string newURL;
char choice;
int pageComp;
cout << "Enter your choice from the ones below: " << endl;
cin >> choice;
if ((choice == "R")|| (choice == "r")) { // chars use ' ', " " are for strings
cout << "Enter the URL you want to search for: " << endl;
cin >> newURL;
bool pageComp = pageURL.compare(newURL); // Oops! Compare wants CacheType,
// but gets std::string!
}
| |
Pair your if-elses. They mismatch in
main()
.
After fixing these problems, your code should compile, so we might start finding bugs related to OOD :D