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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:39:54+00:00 2026-06-04T10:39:54+00:00

I will try to describe the context of the problem a bit, and then

  • 0

I will try to describe the context of the problem a bit, and then some observations. I do not have a specific question; I am just looking for advice, primarily.

I have a number of .h files which correspond to test/demos for the user. Each .h file defines one class corresponding to one test/demo. It should be noted that all these classes inherit from a common base.

In my main file, I need to #include all these .h files and identify each of their classes. Then, for n classes, there will be n buttons. Each button, when pressed, creates a new instance of the class it corresponds to. When released, it deletes it. The buttons cannot have their own instantiation stored; they must be created and deleted when pressed and released; it is imperative that that no two instances of different classes be instantiated at the same time.

This raises a few issues (and to clarify the context):

  1. All of the information about a particular test/demo should be in the same place (i.e., the test’s name, the test’s filename, and the test’s class name should all be in the same area of the code. Preferably the same line. This is just good design.
  2. A key piece of information of the class is its C++ name. Unfortunately, as far as I know, such tokens can only be written into code that instantiates it (so it cannot, for instance, be stored in a struct containing information about each test/demo; I tried templates, but then it was a list of templates whose arguments all differed).

Point 1 and point 2 led me to make a macro expression of the following form:

#define TESTDEMO_DATA(MACRO)\
    MACRO("<name 1 here>",class1_symbol,"<filename 1 here>")\
    MACRO("<name 2 here>",class2_symbol,"<filename 2 here>")\
    MACRO("<name 3 here>",class3_symbol,"<filename 3 here>")\
    ...

From here, I could very simply create buttons (I used TESTDEMO_DATA to generate functions that would create instances of classn_symbol, and then just had each button call the right one).

But now I am stuck: I clearly cannot write a macro that to pass to TESTDEMO_DATA that will #include just the filename, as I might like, because that would require a multipass preprocessor. I don’t want to write the #includes separately either, because that violates point 1, though it’s the best I can think of right now.

Ideas?

  • 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-04T10:39:55+00:00Added an answer on June 4, 2026 at 10:39 am

    Generate code from a script.  

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

Sidebar

Related Questions

I am not sure if I can describe the problem, but I will try
I have the following problem, will try to describe it shortly. In my program
I will try describe my problem as best as I can. I have created
This is kind of a oddball problem so I will try to describe the
Hmm.. I am not sure how to describe this. But I will try So
Hello everyone I have a question that I will describe as good as I
I'm not sure how to describe this, but I'll try with some basic code:
ok is hard for me to describe my problem now but then i will
I am trying some DDD and I will try to describe in most simple
I will first describe the problem and then what I currently look at, in

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.