=====Zeiger unter ""C++""===== engl. pointer http://www.num.math.uni-goettingen.de/Dokumentationen/C/Einfuehrung/zeiger.html#Zeigerzeiger ====Examples==== %%(c) mTyp aName; // Declaration of aName printf( "%d", &aName ); // Print address of aName %% %%(c) mClass *mName; // Declaration of a pointer t class mClass named mName mClass* mName; // Declaration of a pointer t class mClass named mName (*mName).function(); // Call to a method function() in the class mKalsse mName->function(); // Call to a method function() in the class mKalsse %% %%(c) mTyp** mName; // Pointer to pointer of mName mName = new int*[5]; // Create a Pointer to an 1dim array of size 5 mTyp**** mName; // equivalent.... %% %%(c) // create an new object of type mKalsse named oKlasse mClass oKlasse = new mClass(); // Something() returns a pointer to another class oKlasse2* p2 = oKlasse.Something() // Print address printf( "%d", p2 ); // Call to a method of the class p2 points to p2->Method(); %% %%(c) // short way to call the method Method() oKlasse.Something()->Method(); %% %%(c) // create new array int* a = new int[3]; %% %%(c) // create new array mClass50 is a pointer to a array of 50 classes of type mClass (mClass50**) mClass** a = new mClass*[50]; // a fast way to copy the 50 pointers if type mClass to an other array a memcpy(a, mClass50, (50*sizeof(mClass*)); %% %%(c) int av=1; int *a; a= &av; printf("%d\n",*a); %% ==a==Pointerarithmetik==a== für %%(c) short int i float ar[10] %% gilt Zugriff auf das erste Element %%(c) *ar ar[0] %% Zugriff auf den Zeiger des ersten Elements %%(c) &ar[0] ar %% Zugriff auf ein beliebiges Element %%(c) *(ar + i) ar[i] %% Zugriff auf die Bytes des Arrays %%(c) *((unsigned char*)ar + i) ((unsigned char*)ar)[i] %% ---- Siehe auch {{backlinks}}