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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:28:18+00:00 2026-05-22T22:28:18+00:00

This is an interview question: how can we store the objects of let’s say

  • 0

This is an interview question:
how can we store the objects of let’s say 3 different classes which are totally independent of each other.

My answer was:
create an array which stores all void pointers.
like :

void *array[];

and store the pointers of all the objects.the array elements can be many.
but for retrieving the elements,i said we can use the dynamic cast or the static cast!
this i think is the wrong answer.i think dynamic cast and static cast are supposed to be used among the classes which are dependent.
please correct me if i am wrong.

if dynamic cast and static cast doesn’t work.May be we can use reinterpret cast.

but is this the correct way to do this task?

  • 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-22T22:28:19+00:00Added an answer on May 22, 2026 at 10:28 pm

    Why are you trying to make this so complicated?

    struct T {
       T1 obj1;
       T2 obj2;
       T3 obj3;
    };
    

    If you instead mean that you have an array of objects, and each element can be of any of three distinct, unrelated types, then it’s a silly interview question because it’s a silly thing to do.

    (Yes, you would consider reinterpret_cast if forced to employ this approach by limited job opportunities and a pressing need to consume food.)

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

Sidebar

Related Questions

I can't figure this interview question. You have an array of integers. You need
This is a popular interview question and the only article I can find on
This question was asked to me in an interview: Lets say you have a
This is an interview question & I'm looking wht experts can answer in a
I came across this post , which reports the following interview question: Given two
This was an interview question. Given Visual Studio 2008 and an icon saved as
I was browsing Scott Hanselman's Developer Interview question list , and ran across this
I was asked this question in a job interview. The interviewer and I disagreed
I was asked this question during an interview. They're both O(nlogn) and yet most
This was an job placement interview I faced. They asked whether we can realloc

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.