Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda