Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Using a string/char* to get member of a namespace, class, struct, instance

So in javascript we can access the member of any object by just using []. For example:

let obj = { foo : 'bar'};
let accessedField = obj["foo"];
obj["foo"] = "something"

How can I access a member of a namespace without knowing the name of the member beforehand like if I get it from somewhere else as input, a string/char* for example. Not necessarily looking for the operator[] implementation.

namespace Foo {
   int bar = 2;
}

Foo["bar"] = 3;

The reason is so I can dynamically access items and I don't want too use std::maps.

**EDIT: Just to clarify not necessarily the [] operator but any way to dynamically access a member of a namespace without knowing it beforehand.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!