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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:21:30+00:00 2026-05-25T19:21:30+00:00

I am writing a program that can take in either 3 ints, or 3

  • 0

I am writing a program that can take in either 3 ints, or 3 floats in the constructor(I suppose I will need 2 constructors for this). I want to declare an array and store the values in the array “numbers”.

If I don’t know which constructor will be called I am not sure how to declare “numbers”(as an int array or as a float array).

Is there a good technique to get around this? or can I create an int array and a float array and somehow have a generic pointer to the array being used(is using a void pointer the best way to do this)?

  • 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-05-25T19:21:30+00:00Added an answer on May 25, 2026 at 7:21 pm

    Looks like you want a templated class.

    template <class T>
    class Foo
    {
    public:
        Foo(T a, T b, T c)
        {
            numbers[0] = a;
            numbers[1] = b;
            numbers[2] = c;
        }
    private:
        T numbers[3];
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Perl program that will take a few command-line arguments (they'll actually
I noticed that I can start a program with it's associated handler by writing
Maybe you can help me... I am writing a program in Windows Mobile that
I am writing a program that will draw a solid along the curve of
I am writing a c++ program which sooner or later will need to be
I am trying to write a fragment program that will take a texture and
The program that I am writing needs to do this: read every line of
I'm writing a program that needs to take input from an XBox 360 controller.
My program that I am writing's purpose arose with this issue: There are two
Im writing a program that should read input via stdin, so I have the

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.