Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8954681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:21:49+00:00 2026-06-15T14:21:49+00:00

ok, I know this is probably going to be something really easy but I

  • 0

ok, I know this is probably going to be something really easy but I have this code implementing the boost libraries (this is my first time using it) and I can’t seem to get it to work correctly. here’s the code.
hash.h

#include .....
#include "boost/unordered_set.hpp"
#ifndef HASH_H
#define HASH_H

class hash{
public:
    int toHash(string);
    void insertKey(string);
    bool lookupKey(string);
private:
    string hashTable[];
    vector<string> vfile;
    typedef boost::unordered_set<std::string, int> um;
struct hashkey{
    string state;
    int stateno;
};

};

#endif  /* HASH_H */

also the hash.cpp

#include <boost/unordered/unordered_set.hpp>
#include "hash.h"

int hash::toHash(string key){
    unsigned int x;
    std::stringstream ss;
    ss << std::hex << key;
    ss >> x;
    return x;
}

void hash::insertKey(string key){
    um.insert(key,toHash(key));
}

bool hash::lookupKey(string key){
    return um.find(key)==um.end();
}

I’m getting “hash.cpp:18:7: error: expected unqualified-id before ‘.’ token”. And I reiterate, I know it’s probably quite easy, I just haven’t used boost libraries before. I looked at many examples on the internets and I can’t seem to just get this “simple” piece to work.Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:21:51+00:00Added an answer on June 15, 2026 at 2:21 pm

    Your um isn’t a member variable, it’s a typedef. Get rid of the typedef keyword.

    Now with regard to your second issue……

    Get rid of your hash computation member method & the template’s second arg. Get rid of insert()’s second arg. boost unordered_set already provides hash functions for many standard types, including std::string. If you want to hash a user-defined type, though, you will need to provide a hash function, but not in the way you’re doing it here. You’d create an overload of a function named hash_value() like this:

    std::size_t hash_value(yourUserDefinedType_probablyAClassName const &t) 
    {
        std::size_t retValue;
        //...compute your hash however you want & store in retValue....
        return retValue;
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this is probably super easy, but I'm having a hard time wading
I know this probably really simple but Im not sure what im doing wrong...
I know this is probably something simple but I can't seem to find anything
I know this is probably a really amateur question, but I can't figure this
This is going to be a really dumb question, I just know it, but
This is probably going to be embarrassing, but here we go! I have the
I know this probably has been asked before but I am having issues with
I know this has probably been asked before but for my problem I cannot
I know this is probably possible using Streams, but I wasn't sure the correct
I know this is probably a very simple question but how would I do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.