473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Template: Structure inside class.

Hello,
I am trying to implement hash table functionality using templates.
I need to declare the hash table element as a struct or class inside the HTable template...
I get following compilation error. Why does compiler fail to associate <RecordType> with HTElement::entry ?



driver.cpp:131: instantiated from here
./htable.icc:66: error: no match for 'operator=' in '((hashtable::HashTable<Cont
act>*)this)->hashtable::HashTable<Contact>::data[index].hashtable::HashTable<Con
tact>::HTElement::entry = entry'
./contact.hpp:71: note: candidates are: Contact& Contact::operator=(Contact&)
./htable.icc: In member function `void hashtable::HashTable<RecordType>::find(st
d::string, bool&, RecordType&) const [with RecordType = Contact]':
driver.cpp:164: instantiated from here
./htable.icc:117: error: no match for 'operator=' in 'result = ((const hashtable
::HashTable<Contact>*)this)->hashtable::HashTable<Contact>::data[index].hashtabl
e::HashTable<Contact>::HTElement::entry'





here is the code I have..

template <class RecordType>
class HashTable
{
public:
//Member Constant
static const std::size_t CAPACITY = 20;

//Constructor
HashTable();

void insert(const RecordType& entry, std::string key);

void remove(std::string key);

//Constant Member Functions
bool is_present(std::string key) const;

void find(std::string key, bool& found, RecordType& result) const;

std::size_t size() const {return used;}

void toArray(RecordType* array, int size) const;

private:
//Member Constants
static const int NEVER_USED = -1;
static const int PREVIOUSLY_USED = -2;
static const int IN_USE = 1;

//Member Variables
typedef struct HTElement_tag {
public:
RecordType entry;
std::string key;
int status;
}HTElement;

HTElement data[CAPACITY];

std::size_t used;

//Helper Functions
std::size_t hash(std::string key) const;
std::size_t next_index(std::size_t index) const;

void find_index(std::string key, bool& found, std::size_t& index) const;

bool never_used(std::size_t index) const;
bool is_vacant(std::size_t index) const;
};
Jun 14 '07 #1
1 5954
weaknessforcats
9,208 Expert Mod 8TB
I have no idea.

I compiled your code with Visual Studio.NET 2005 and got no errors.

What kind of compiler are you using???
Jun 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tino | last post by:
From Stroustrup( TC++PL, Appendix C.13 ) I thought that this was the way (and the only way perhaps) to have a common static member for all classes generated from a template. Though compiling this...
4
by: Amadeus W. M. | last post by:
What is the difference between friend ostream & operator<<(ostream & OUT, const Foo & f){ // output f return OUT; } and template <class X>
7
by: quarup | last post by:
I want to specialize a template function that lives inside a class, but am getting a compile error in VS.net 2003. Here's my code: template <class T> class A { public: template <class U> void...
8
by: Paul Roberts | last post by:
Hi, I'm hoping somebody here can help me with a simple problem of template syntax. Here's an example: template<typename T, int iclass A { static int a;
7
by: mathieu | last post by:
Hello, I did read the FAQ on template(*), since I could not find an answer to my current issue I am posting here. I have tried to summarize my issue in the following code (**). Basically I am...
1
by: vedanu | last post by:
Hello Friends, I have a generic class protoC which has to take the message from different classes and append its own header and send to the other classes. class protoC; { public:...
4
by: suman.nandan | last post by:
Hi C++ Experts ! I have a little weird requirement. I have a base class, say B and lots of classes D1 .. Dn publicly derived from it. Over the course of development the number of derived...
1
by: farseerfc | last post by:
Hi, everyone here loves C++; As a student studying data structure, I'm writting a single list (with only one pointer to identity the next node in its node struct) simulating std::list like: ...
12
by: nooneinparticular314159 | last post by:
Hello. If I declare the following: template<int a, int b, int SomeArray> class DoSomething{ public: .. .. ..
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.