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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:13:04+00:00 2026-06-15T21:13:04+00:00

I just think about this case, I want to declare a class C which

  • 0

I just think about this case, I want to declare a class C which extends from other classes dynamically.
Suppose that I have class A and class B. Now, I want the class C extends A or B base on a specified condition such as:

#ifdef USE_CLASS_A
class C: A
#else 
Class C: B
#endif

How can I do this in Objective-C?

UPDATE: I just need dynamic at compile time, not runtime. I mean, during compiling time, the class C will extend A or B. This extending will be go forever, don’t change at runtime.

  • 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-15T21:13:05+00:00Added an answer on June 15, 2026 at 9:13 pm

    Based on your update the answer is yes – using #if/#ifdef you can determine at compile time whether class C extends class A or class B in exactly the way you have suggested.

    Of course classes A & B better provide same set of common methods and your code only call those methods, or else you will need further conditional code (compile or runtime) at the points you use class C.

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

Sidebar

Related Questions

I've been thinking about this and I just can't think of a way to
Well I want your opinions about this case: I need a database that will
One could think of this case as follows: The application dynamically loads a module,
I have read much information about agile and waterfall and I just cannot think
just think that when I opened my file then when I want to write
I think this is just a Best Practices question, but I was wondering if
Here is my model_users class (the model it extends from doesn't have anything yet
I have a domain model that looks like this: case class Account(id: Int, name:
I am learning about require.js and think I am just missing something. I don't
I'm not a beginner, but the more I think about this issue, the more

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.