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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:13:19+00:00 2026-06-11T20:13:19+00:00

Isn’t it possible to have a reference to an Objective C protocol inside a

  • 0

Isn’t it possible to have a reference to an Objective C protocol inside a C++ class? The

(id)<B2ContactListener> _B2ContactListener;

line results in two errors:

‘Expected ; at end of declaration list‘

and

‘C++ requires a type specifier for all declarations‘.

Here’s the code.

B2_ContactListener.mm:

#import "Box2D.h"
#import "B2_ContactListener.h"

class ContactListener : public b2ContactListener
{
private:
  (id)<B2ContactListener> _B2ContactListener; // ERRORs

public:
  //Methods
};

B2_ContactListener.h:

#import "B2_Contact.h"

@protocol B2ContactListener
-(void)B2BeginContact: (B2Contact*) contact;
@end

I’m using the current XCode compiler BTW.

  • 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-11T20:13:20+00:00Added an answer on June 11, 2026 at 8:13 pm

    Drop the parentheses:

    id<B2ContactListener> _B2ContactListener;
    

    That should work.

    Another thing you may want to consider is making it an NSObject * instead, so you can invoke methods inherited from NSObject without having to cast.

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

Sidebar

Related Questions

Isn't it possible to open two files simultaneously using different ofstreams? What I am
Isn't having String enough? Just as an example, why can String class lets you
Isn't A a = new A(); // A is a class name supposed to
Isn't possible facebook allow us from my apps post or share image to user
Isn't every language compiled into low-level computer language? If so, shouldn't all languages have
Isn't var a keyword in C#? But why can I do this: public class
Isn't it much more elegant and neat to have an IStringable interface? Who needs
Isn't possible to retrieve auto lock value? Or anyone know how to modify the
Isn't there any built in class in PHP that has HashTable in PHP? If
isn't it possible to rename tags within the app.config? If I use the following

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.