im new in objective c.i have come out with the getter and setter but not sure is correct or not. .h #import <UIKit/UIKit.h> @interface ViewController : UIViewController @property(nonatomic, retain) NSString *myText; @property(nonatomic, copy) NSNumber *opacity; @property(nonatomic, assign) id delegate; @end .m #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize myText; @synthesize opacity; @synthesize delegate; //getter -(NSString*)myText{ return myText; } -(NSNumber*)opacity{ return opacity; } -(id)delegate{ return delegate; } //setter -(void)setMyText:(NSString *)_myText{ if(myText!=_myText){ [myText release]; myText=[_myText retain]; } } -(void)setOpacity:(NSNumber *)_opacity{ if (opacity!=_opacity) { [opacity release]; opacity=[_opacity copy]; } } -(void)setDelegate:(id)_delegate{ delegate=_delegate; } - (void)viewDidLoad { [super viewDidLoad]; // Do any …

Member Avatar
+0 forum 0

Just a thought that woke me up this morning. A means of providing 'property' type constructs in C++ classes similar to python properties. # Header # #ifndef _HXX_CPROP #define _HXX_CPROP /** * Helper class to connect a 'property' in a * c++ class to getter/setter methods * */ template<class T, typename V> class property { public: /** * \brief ctor */ property(T* _target, V (T::*_getter)(void) const = (V (T::*)(void))0L, V (T::*_setter)(V value) = (V (T::*)(V value))0L) ; /** * assignment operator. Provides setter * parent.field = value * functionality */ V operator=(V value) ; /** * coveration operator, provides 'getter' …

Member Avatar
Member Avatar
+0 forum 6

**Tic-Tac-Toe without a class** Write a modular program that allows two players to play a game of tic–tac-toe. Use a two-dimensional char array with 3 rows and 3 columns as the game board. Each element of the array should be initialized with an asterisk(*). The program should display the intial board configuration and then start a loop that does the following. · Allow player 1 to select a location on the boardfor an X by entering a row and column number. Then redisplay the board with an X replacing * in the chosenlocation. · If there is no winner yet …

Member Avatar
Member Avatar
+0 forum 3

Hello, I am asking about true syntax of the following:: I have a class name P and in header file (of this class) ------> [CODE] class P { public: P(); ~P(); void addItem(const int newItem); void deleteItem(const int Item); void showAll(); /** need to proper getter funct. of tail */ private: struct Node { int item; Node *next; Node *precede; }; int size; Node *tail; }; [/CODE] Now I am asking that how I can write getter function of tail ? -class P will be used by another class. Thanks for replying.

Member Avatar
Member Avatar
+0 forum 4

i have problem about the output in this code, my output so only the index 0. how can i fix this. [code] public class d_2D { static double[][] d =new double[6][4]; static double[][] e= {{}, {0.0,0.6,0.0,0.0}, {0.0,0.2,0.5,0.1}, {0.0,0.2,0.5,0.4}, {0.0,0.2,0.5,0.7}, {0.0,0.0,0.0,0.9}}; static double[] avg= new double[4]; static double[] sum= new double[4]; static int i,j,k; public double getAverage(int j){ return avg[j]= sum[j]/k ; } public void setAverage(int i, int j,int k){ //average of column for(j=1;j<e[1].length;j++){ sum[j]=0.0; k=0; for( i= 1; i < e.length; i++) if(e[i][j]>0.0){ sum[j] += e[i][j]; k++; } } } public double getElement(int i, int j) { return d[i][j]=Math.abs(e[i][j]-avg[j]); } …

Member Avatar
Member Avatar
+0 forum 4

Setter getter ..? what is this and what it does ? i searched over google but didn't find the suitable answer...!

Member Avatar
Member Avatar
+0 forum 23

The End.