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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:16:49+00:00 2026-06-10T00:16:49+00:00

Is it possible to generate sets in a loop, where the loop comes up

  • 0

Is it possible to generate sets in a loop, where the loop comes up with a new name for the set?
I am trying to do the following:

//create storage structure for options according to hops
int lengthOfStart = start.length();
for (int i = 0; i<start.length();++i) {
    string nameOfSet = "Hop" + i;
    Set<string> nameOfSet;        
    wordLadderOptions.enqueue(nameOfSet);

}

I am using a slightly modified version of traditional c++ set which just offers some more functions for data manipulation but otherwise the set is same as the one built in to c++ standard library. When I say Set<string> nameOfSet; the compiler sees this as the actual name of the set and not a variable…

How can I make it see it as a variable in order to create sets in the for loop based on the variable i’s value?

  • 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-10T00:16:50+00:00Added an answer on June 10, 2026 at 12:16 am

    Variable names don’t exist in C++ after compilation (apart from debugging info). So your request isn’t very meaningful. Perhaps you want to associate each set with a name and stick them in a map<string, Set>?

    In a language like Python which actually does let you do this, that’s what’s happening behind the scenes. The only difference is that variable names are implicitly looked up in a dict at runtime.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two sets, returned by Set.Make(t). I would like to generate every possible
Is it possible to generate a set of wiki pages from XML comment file
Is it possible to generate Server side includes with express.js? I'm trying to reuse
How can I generate all the possible nondecreasing sets of the elements of a
Is it possible to generate a new ID for the session using ASP.NET? I
Is it possible to generate the same random number in python as in java
While it is possible to generate PowerPoint presentations automatically using Office Automation , this
Is it possible to generate a random number between 2 doubles? Example: public double
Is it possible to generate the database tables and c# classes from NHibernate config
Is it possible to generate a file in javascript and then prompt the user

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.