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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:41:28+00:00 2026-06-16T16:41:28+00:00

I would like to know if it’d be possible (and if, how) to create

  • 0

I would like to know if it’d be possible (and if, how) to create a pointer of X value
Now, let’s say I know which types would be possible to be assigned in this pointer.

For example, a pointer of X value (of course feel free to change the name of this value), that’d be able to point to variables of string, bool and a custom class

  • 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-16T16:41:28+00:00Added an answer on June 16, 2026 at 4:41 pm

    Usually what you describe is a bad idea.

    void* works, for marginal values of works. It throws out all type safety, requiring you to keep track of it.

    Creating a root type sort of works, but it doesn’t work for primitive types, and is rather intrusive.

    A boost::variant< bool*, std::string*, MyClass* > is a variable that can contain a pointer to any one of these 3 types (bool, std::string or MyClass). You will probably find it challenging to use, because it enforces type safety, and the syntax can get annoying.

    Similarly, a pointer to boost::variant< bool, std::string, MyClass > may be what you want, but it doesn’t let you point to bool variables you aren’t fooling around with.

    With full C++11 support, union can contain arbitrary types, together with an enum can let you do something very much like a boost::variant. As a downside, this requires the thing you be pointed to be a union. With or without full C++11 support, a union of pointers is reasonable. In both cases, you’ll have to track the type manually and keep it in sync.

    What you really need to think about is “why am I asking this?”, because as with many questions, the motivation matters. You may not be asking the right question.

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

Sidebar

Related Questions

Would like to know now if this should be possible. A user visits my
I would like know if it is possible to create embedding of audio message
I would like to know if it's possible to create multiple projects with the
Would like to know if it is possible to create a MessageBox with custom
Would like to know which library (open source preferable) should I use to create
Would like to know is that possible to have filter with default value with
I would like to know how. I have looked at this topic , and
This is possibly a candidate for a one-line answer. I would like know it
would like to know how can this be implemented in Joomla. I have a
I would like to know which steps and which concepts do you follow when

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.