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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:41:35+00:00 2026-06-12T08:41:35+00:00

This is the struct that I have and I’m trying to write the default

  • 0

This is the struct that I have and I’m trying to write the default constructor for that.

struct Cnode
{
typedef std::map<char, int> nextmap;
typedef std::map<char, int> prevmap;

Cnode() : nextmap(), prevmap() {} //error
Cnode(const nextmap2, const prevmap2) : nextmap(nextmap2), prevmap(prevmap2) {}

};

Please help me understand what this error means:

Type 'nextmap'(aka 'map<char,int>') is not a direct or virtualbase of 'Cnode'
Type 'prevmap'(aka 'map<char,int>') is not a direct or virtualbase of 'Cnode'
  • 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-12T08:41:36+00:00Added an answer on June 12, 2026 at 8:41 am

    Because nextmap and prevmap aren’t variables, but types. As clearly indicated by the typedef (it defines a type).

    Did you mean:

    struct Cnode
    {
    std::map<char, int> nextmap;
    std::map<char, int> prevmap;
    
    Cnode() : 
      nextmap(), prevmap() {}
    Cnode(const std::map<char, int>& nextmap2, const std::map<char, int>& prevmap2) : 
      nextmap(nextmap2), prevmap(prevmap2) {}
    
    };
    

    or perhaps this might clear your confusion:

    struct Cnode
    {
    typedef std::map<char, int> MapOfCharToInt;  //defines a new type
    
    MapOfCharToInt nextmap;                      //defines variables
    MapOfCharToInt prevmap;                      //of that type
    
    Cnode() : 
       nextmap(), prevmap() {} 
    Cnode(const MapOfCharToInt& nextmap2, const MapOfCharToInt& prevmap2) : 
       nextmap(nextmap2), prevmap2(prevmap2) {}
    
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C++ struct that looks like this: struct unmanagedstruct { int flags;
I have this struct: typedef struct { void (*func)(instruction); union { double db; char
I have a C (not C++) struct that goes like this typedef struct mystruct{
I have a struct that looks like this: struct queue_item_t { int id; int
I have a C structure like this : typedef struct ip_esp_private { /* keep
I have this look up table : char *table[ascii][morse]; where ascii is an int
I have a C struct that is defined in a way similar to this:
If I have some code that looks something like: typedef struct { bool some_flag;
I have read that if you declare two structs like this: struct Node {
Summary: I have a struct that is read/written to file. This struct changes frequently,

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.