Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MACnus

macrumors newbie
Original poster
Dec 13, 2004
1
0
I'm currently converting a code from visual c to objc.

I have problems when using [] on method declarations

+ (id)Normal:(CVector *)vPolygon[];

this brings a parse error

waht do i have to do?

Thanks
 

iRobert

macrumors newbie
Mar 11, 2004
17
0
the Netherlands
If you are [trying to define the input argument as an array], simply define the function like this:

+ (id)Normal:(CVector **)vPolygon;

you can then access it using (*vPolygon)[n];

see the following example: (it's ObjC version is trivial)

Code:
#include <iostream>

void printList(int ** list);

int main (int argc, char * const argv[]) {
	int	*myList	= (int *)malloc(3*(sizeof(int)));
	
	myList[0] = 12;
	myList[1] = 14;
	myList[2] = 16;
	
	printList(&myList);
	
     free(myList);

     return 0;
}

void printList(int ** list) {
	std::cout << (*list)[0] << std::endl;
	std::cout << (*list)[1] << std::endl;
	std::cout << (*list)[2] << std::endl;
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.