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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:48:56+00:00 2026-05-27T21:48:56+00:00

had a two part question with regard to below contrived c++ code snippet :

  • 0

had a two part question with regard to below contrived c++ code snippet :

 namespace {

  struct FieldRecord {

     string item_to_fieldname;
     bool is_queriable;
   };

   const FieldRecord g_LookUpTable [] = {

       {"employee_name", true},
       { "ssn_no", false},
        //etc 
   };

 }

1) if i wanted to implement a lookup table of a structure that is non -pod is the following C style approach error prone or is it neccessary to make the structure FieldRecord a pod i.e replace string with const char* etc

2) how does the FieldRecord structure for the array in the above structure get initialized from the initialization list since i have only a default constructor .

  • 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-27T21:48:56+00:00Added an answer on May 27, 2026 at 9:48 pm

    Your FieldRecord isn’t a POD. It is an aggregate, however. To use direct initialization it is sufficient to have an aggregate. If your type becomes a non-aggregate, you’ll need to use a constructor. For aggregates you can just list the values the respective members should get and they’ll get initialized directly, possibly involving a conversions for the members.

    The question then becomes: what is an aggregate? Well, it is any class which has neither constructors nor a destructor, no private or protected non-static data members, no base classes, and no virtual functions. If you need any of those, you’ll need to give your type a constructor and construct from there. It is a bit more repetitive but you can still fill an array with these objects. For example:

    std::pair<std::string, bool> const table[] = {
        std::pair<std::string, bool>("employee_name", true),
        std::pair<std::string, bool>("ssn_no", false)
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a link to a question I had asked two days back, How
This is actually a two-part question. My server is set up to redirect all
This is really a two part question, since I don't fully understand how these
This is a two part question. I have a class that gets all processes
this is a two part question that probbably have a similar answer. I want
I was asked this question in an interview. If you had two numbers represented
This is a two part question, but I want to make sure the first
I had two separate interfaces, one 'MultiLingual' for choosing language of text to return,
If you had two snippets: (global-set-key \C-d delete-char) and (define-key global-map \C-d delete-char) Is
Originally I had two tables in my DB, [Property] and [Employee]. Each employee can

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.