Skip to content

Instantly share code, notes, and snippets.

@wilhuff
Created September 3, 2019 19:21
Show Gist options
  • Save wilhuff/bad317cb1333fe0507c2f60035e88894 to your computer and use it in GitHub Desktop.
Save wilhuff/bad317cb1333fe0507c2f60035e88894 to your computer and use it in GitHub Desktop.
id in C++ class works from Objective-C

Build and test like so:

$ clang++ -std=c++11 test_class.cc main.mm -framework Foundation
$ ./a.out
2019-09-03 12:18:13.640 a.out[85486:6585983] The answer is 42
#import <Foundation/Foundation.h>
#include "test_class.h"
int main() {
TestClass tc;
NSLog(@"The answer is %d", tc.id());
return 0;
}
#include "test_class.h"
int TestClass::id() const {
return 42;
}
class TestClass {
public:
int id() const;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment