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

  • Home
  • SEARCH
  • 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 struct that looks like this: typedef struct _my_struct { float first_vector[SOME_NUM][OTHER_NUM];
I have a struct that I initialize like this: typedef struct { word w;
I have a Deque that contains this kind of stucts. struct New_Array { array<array<int,4>,4>
I have this type which is basically a struct { int x,y,z; } that
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 struct that's defined like this: struct Vec3 { float x, y,
I have a struct that looks something like this: [StructLayout(LayoutKind.Sequential)] public struct in_addr {

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.