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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:44:39+00:00 2026-05-28T02:44:39+00:00

I cannot seem to access the map in the parent class from the child

  • 0

I cannot seem to access the map in the parent class from the child class, as I try to output the contents of the map and nothing is displayed.

BELOW I HAVE ADDED IN THE FULL CODE, OVERALL IF I POPULATE THE MAP IN THE transLateMask() it will then print out the contents, however if i populate the map in the populate() it will print out nothing and I do not know why?

Here is my code.

//HEADER FILE
//////PARENT CLASS
#include <iostream>
#include <string>
struct TTYElementBase 
{
    //some code here
};

class element
{
    public:
    std::map<char,std::string> transMask;
    std::map<char,std::string>::iterator it;
    void populate();
};

//////CHILD CLASS .HPP

class elementV : public element
{
    public :
    std::string s1;
    std::string s2;
    elementV();
    friend ostream &operator<< (ostream &, const elementV &);
    void transLateMask();
};

//CPP FILE #include "example.h"

elementV::elementV()
{
}

void element::populate()
 {
    transMask['D']='D'; //WILL PRINT OUT NOTHING IF I POPULATE HERE 

 }


void elementV::transLateMask()
{

    for ( it=transMask.begin() ; it != transMask.end(); it++ )
        std::cout << (*it).first << std::endl;
}

int main()
{
    element e;
    e.populate();
    elementV v;
    v.transLateMask();
}

It doesn’t output anything – why is that?

  • 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-05-28T02:44:39+00:00Added an answer on May 28, 2026 at 2:44 am

    The call to e.populate() populates e.transMask, not v.transMask. You need to call v.populate().

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

Sidebar

Related Questions

I cannot seem to get hold of the parent varible from the child template,
I cannot seem to use a Windows account to access my database from my
I cannot seem to figure out how to access my Model from my View.
I cannot seem to access the context object using a loop context is set:
I have this design which I cannot seem to get right, I would like
I have a relatively simple question that I cannot seem to find the answer
I have a weird error that I cannot seem to find any documentation or
I have an issue using the Dynamic Expression API. I cannot seem to compare
I have developed an object pool and cannot seem to do it without using
I have a linked table in ms-access that pulls data from a mysql database.

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.