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

  • Home
  • SEARCH
  • 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 5928109
In Process

The Archive Base Latest Questions

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

struct { int integer; float real; } first_structure; So we can refer to a

  • 0
struct
{
int integer;
float real;
}
first_structure;

So we can refer to a member of the first_structure by writing

first_structure.integer = 7

If I write:

    struct two_numbers
    {
    int integer;
    float real;
    }
    first_structure;

then I can use the tag *two_numbers* to create a second structure like this:

struct two_numbers second_structure;

I also understand that typedef can be used to create synonyms.

But I am unable to understand the code below (from the page http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocObjectsClasses.html):

typedef struct objc_class *Class;
typedef struct objc_object {
    Class isa;
} *id;

Every object thus has an isa variable that tells it of what class it is an instance.

HOW can it tell???? Please guide me through the meaning of this code.

Thank you.

  • 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-22T14:15:19+00:00Added an answer on May 22, 2026 at 2:15 pm

    That’s a shortcut to:

    struct objc_object
    {
        Class isa;
    };
    typedef struct objc_object * id
    

    The id type is a pointer to an objc_object structure.
    So when using an id type, you will use the -> operator instead of ., since it’s a pointer.

    Note that the Class type is also a pointer to a structure.
    That’s called an opaque type.

    It basically means the compiler will be able to calculate the size, since we have only a pointer, but it won’t know the implementation details.

    That kind of pattern is used to hide the actual implementation of a structure.
    The type is defined in a header file, but the implementation is only defined in a source file.

    For instance, in a header file:

    typedef struct A_Struct * A;
    

    That’s valid, and it defines a type to a structure pointer, even if that structure is not known actually.

    Then in a source file:

    struct A
    {
        int x;
        int y;
    };
    

    Here’s the real implementation. Users will be able to create A typed objects, but won’t be able to access the members, since they are known only in your source file.
    Users will pass you A typed objects, but you’ll be cast them to a struct A, so you can access it members.

    IE:

    void foo( A someObject )
    {
        struct A * a;
    
        a    = ( struct A * )someObject;
        a->x = 42;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

struct s { int a; float b; int c; } How is this structure
Consider the following: typedef struct { int a; int b; int c; int d;
Given a struct, e.g. typedef struct { int value; } TestStruct; Why does the
I am curious why this code works: typedef struct test_struct { int id; }
Let's say I have a first structure like this: typedef struct { int ivalue;
struct elem { int i; char k; }; elem user; // compile error! struct
struct SomeStruct { int a; int b; }; SomeStruct someFn( int init ) {
struct Div { int i; int j; }; class A { public: A(); Div&
struct struct0 { int a; }; struct struct1 { struct struct0 structure0; int b;
Consider something like: struct Parameter { int a; Parameter(){a = 0;} void setA(int newA){a

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.