Reference to a class is ambiguous XCode
So I'm building a program with a class. As i reference anything in it i get the error that the reference is ambiguous. Anyone know why?
hash.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
#include <iostream>
#include <string>
#include <cstdlib>
#include "hash.h"
using namespace std;
int hash::Hash (string key)
{
for (int i = 0; i < tableSize; i++)
{
SYMTAB[i] = new item;
SYMTAB[i]->opcode = "empty";
SYMTAB[i]->address = "empty";
SYMTAB[i]-> next = NULL;
}
}
void hash::addItem(string opcode, string address)
{
int index = Hash(opcode);
if (SYMTAB[index]->opcode == "empty")
{
SYMTAB[index]->opcode = opcode;
SYMTAB[index]->opcode = address;
}else
{
item* Ptr = SYMTAB[index];
item* n = new item;
n->opcode = opcode;
n->address = address;
n->next = NULL;
while (PTR->next != NULL ) {
Ptr = Ptr->next;
}
Ptr->next = n;
}
}
int hash::numOfItems(int index)
{
int count = 0;
if (SYMTAB[index]->opcode == "empty")
{
return count;
}
else
{
count++;
item* Ptr = SYMTAB[index];
while (Ptr->next != NULL)
{
count++;
Ptr = Ptr->next;
}
}
}
void hash::itemsInIndex(int index)
{
item* Ptr = SYMTAB[index];
if (Ptr->opcode == "empty")
{
Ptr->next;
}
while (Ptr != NULL)
{
intermidiate<< Ptr->opcode<<Ptr->address<<endl;
Ptr->next;
}
}
void hash::findItem(string opcode)
{
int index = Hash(opcode);
bool itemFound = false;
string address;
item* Ptr = SYMTAB[index];
while (Ptr != NULL)
{
if (Ptr->opcode == opcode) {
itemFound = true;
address = Ptr->address;
}
Ptr = Ptr->next
}
if (itemFound == true)
{
//do something if found
}
else
{
//do something if not found
}
}
|
Ypu need to post the exact error.
Topic archived. No new replies allowed.