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 9298707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:23:14+00:00 2026-06-18T22:23:14+00:00

Basically, I’m trying to make template map/dictionary class for c++ (I know this have

  • 0

Basically, I’m trying to make template map/dictionary class for c++ (I know this have already been done, assume I’m masochistic).

I started up, writing this skeleton:

#pragma once
template <class T>
class AssArray
{
    int _size;
    int _position;

public:
    AssArray(int size);
    ~AssArray(void);

    const T& operator [](char* b) const;
    T& operator [](char* b) const;
        //I read this should be done sth like this when researching, though an explanation would be nice.
};

Now, I need to be able to get (T=AssArray[“llama”]), set (AssArray[“llama”]= T) and override (AssArray[“llama”]= newT).

Doing this is pretty straight forward, just loop it through etc, the real problem here is the operators;

if I use AssArray[“llama”]= T, how am I supposed to get the value of T into the operator overloading-function?

I’ve only found explanations describing the solutions briefly, and can not really follow.
Please enlighten me.

  • 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-18T22:23:15+00:00Added an answer on June 18, 2026 at 10:23 pm

    All you have to do is correct your signatures like so:

    const T& operator [](char* b) const;
    T& operator [](char* b);
    

    I’ve removed the const qualifier from the second operator.

    if I use AssArray["llama"]=T, how am I supposed to get the value of T into the operator overloading-function?

    You don’t. You just return a reference to where the new value should be stored, and the compiler will take care of the rest. If "llama" does not exist in the array, you need to create an entry for it, and return a reference to that entry.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I have a list of delivery checkboxes one for deliver to this address
Basically I am trying to make the in-app purchase work, but with no luck.
Basically I'm trying to reprint this method every time a dropbox option is selected.
Basically I am trying to do this: <Trigger Property=Item Value={c:CollectionView.NewItemPlaceHolder}> But the syntax is
Basically I have code that initialises the database in a DatabaseHelper extended class (see
Basically, I've been trying nXhtml mode, and it's terribly slow and buggy in Emacs
basically ive followed this tutorial here and have everything up and running and working
Basically I want to know how I would do this. Here's an example string:
Basically I have this server app I built in vc#, and for some reason
Basically, I've been trying to complete the 3rd question on projecteuler.net. The example gives

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.