Reference to class is ambiguous??

May 7, 2015 at 4:25am
I keep getting 2 errors in my cpp file for the first line:
Expected a class or namespace

Reference to 'hash' is ambiguous


Please help.....

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

//hash.h file
#ifndef __HashTable__hash__
#define __HashTable__hash__

#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;


class hash{

public:
    int Hash(string value);
    
};

#endif /* defined(__HashTable__hash__) */





//hash.cpp file
#include "hash.h"




int hash::Hash(string key)
{
    
}
May 7, 2015 at 4:47am
I would suggest getting rid of line 10 and making appropriate changes elsewhere.
May 7, 2015 at 5:05am
Wow thanks that worked. But why does it do that would you know?
May 7, 2015 at 5:24am
using namespace std; takes the contents of that namespace and dumps it all into global scope. If you ever try to use a name that happened to be in there, it'll clash. That's why it's good practice to not use such a broad directive, especially in headers when people who use that code might not want the std namespace filling the global one.
May 7, 2015 at 5:28am
awww makes sense. Thanks for the clarification.
Topic archived. No new replies allowed.