Jump to content

Objective C/C++ Pointers using . ?

Objective C Objective C++

  • Please log in to reply
1 reply to this topic



    InsanelyMac Protégé

  • Members
  • Pip
  • 1 posts
I'm starting to get more comfortable using Objective C++ coming from a C/C++ background.
I'm just realizing one of the things that has been confusing me, so I'm wondering if anyone can help me figure it out.
Basically what I realized is that pointers in Objective C++ or Objective C can have . operators (?) to access members, but in C and C++, pointers need -> to access members. I notice that when I access my C and C++ members of objective C++ classes (?), I have to use . to access Objective C++ members (properties?), while simultaneously using -> to access C and C++ members. What is going on with this? What is the meaning of using a . on a pointer in Objective C++? Do I simply have to make pointers of objective C++ class pointers to get objects the way I think of them in C++?
Thanks in advance,




  • Retired
  • 1,161 posts
  • Gender:Male
  • Location:Wonderland
  • Interests:(~_^)
In objective C, pointers uses the asterisk * to denote a pointer. The period is used when you have properties of an object for instance:

@interface MyClass : NSObject

NSObject *Cars;  // an object car

int weight,speed; // just two integer values

// declare the properties of the Class
@property(nonatomic) int weight;
@property(nonatomic) int speed;

Then in your implementation file aka the .m file

@implementation MyClass

@synthesize weight,speed; // must synthesize properties you create

// now you may use the properties

	 Car.weight = 1593;
	 Car.speed = 155;


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2017 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy