Accessors Question Programming Software Development by steveh44 … System.Collections.Generic; using System.Linq; using System.Text; namespace Accessors { class Program { static void Main() { AddUpMethod addUpClassFieldAccess = new AddUpMethod(); AddUpProperties… Re: accessors Programming Web Development by sergb When writing classes you usually provide your own accessors and mutators (getters and setters) for each property that needs … Car Class with constructors and accessors Programming Software Development by mandofl … objects year, make also assign speed 0 to speed member. Accessors to get the values stored in an object's yearModel… Re: Accessors Question Programming Software Development by Geekitygeek Neither way is [B]wrong[/B]; either one is a valid method for passing values to a new object. Which one you use depends more on the situation. For instance, if you have a value that is manadatory or required whilst instantiating the object then placing it in the constructor ensures that it is passed when the object is created. If you plan on … accessors Programming Web Development by delpi767 I'm new to PHP and trying to learn a bit about classes. In most languages if a class member is private, it is accessed through a property which itself has an accessor. So there is a separate accessor for each property It appears in PHP that the __set accessor is the only accessor available for an entire class. Does this mean then that … Accessors for an multidemensional array? Programming Software Development by Zinderin So I have this two dimensional array in my class, and I'm trying to create an accessor group for it. But the compiler doesn't like what I'm trying to do at all. [CODE] private int[,] _resource = new int[5, 2]; public int Resource[int idx1, int idx2] { get { return _resource[idx1,idx2]; } set { _resource[idx1,… Re: Accessors for an multidemensional array? Programming Software Development by finito [CODE=C#]public int Resource(int idx1, int idx2) { get { return _resource[idx1,idx2]; } set { _resource[idx1,idx2] = value; } }[/CODE] Change it to this I changed From [CODE]public int Resource[int idx1, int idx2][/CODE] to [CODE]public int Resource(int idx1, int idx2)[/CODE] Re: Accessors for an multidemensional array? Programming Software Development by Geekitygeek You could move the array to its own class with an indexer then expose an instance of that class through your property: [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); } //store instance of the class holding your array private Resource _resource… Re: Accessors for an multidemensional array? Programming Software Development by Geekitygeek [QUOTE=finito;1293803][CODE=C#]public int Resource(int idx1, int idx2) { get { return _resource[idx1,idx2]; } set { _resource[idx1,idx2] = value; } }[/CODE] [/quote] That wouldnt work :/ By adding the parameters it will be treated as a method instead of a property and a method will not recognise … Re: Accessors for an multidemensional array? Programming Software Development by finito [QUOTE=Ryshad]That wouldnt work :/ By adding the parameters it will be treated as a method instead of a property and a method will not recognise the get/set syntax. [/QUOTE] Ahh yes I see my error. Sorry about that. It seems I didn't know what I was talking about. Thanks Ryshad. Re: Accessors for an multidemensional array? Programming Software Development by Geekitygeek No worries, we all make mistakes; The day you stop learning is the day you die, we're all here to help one another to learn :) Re: Accessors for an multidemensional array? Programming Software Development by Zinderin Well, I had to move forward so I made a GetRes() and SetRes() methods ... but I am still curious if it is possible ... there's just too many scenarios where a class will have a property that could be multi-dimensional. However, Microsoft being Microsoft could have taken the position ... properties are not objects (which includes arrays) and just … Re: Accessors for an multidemensional array? Programming Software Development by Geekitygeek Umm...did you overlook my post? I showed you how to use an indexer to produce the access you wanted. Granted, you have to move the array out into a seperate class, but the end result is what you asked for. Re: Accessors for an multidemensional array? Programming Software Development by Zinderin [QUOTE=Ryshad;1295538]Umm...did you overlook my post? I showed you how to use an indexer to produce the access you wanted. Granted, you have to move the array out into a seperate class, but the end result is what you asked for.[/QUOTE] No no, I didn't overlook your post Ryshad ... there's a couple of people up here who's opinion I always read ...… Re: Accessors for an multidemensional array? Programming Software Development by Geekitygeek Ah, OK..just checking you hadn't skipped over it :) I'm glad you have found a solution that works for you..but just for my own piece of mind; what was the problem with the indexer method? To my mind [iCODE]SomeClass.SomeArray[0,0] = 1;[/iCODE] reads much better than [iCODE]SomeClass.SetValue(index1, index2, value);[/iCODE] :p Re: Car Class with constructors and accessors Programming Software Development by mandofl Ok here is what i have for the code. [CODE= cplusplus] #include <iostream> #include <cstring> #include <cctype> using namespace std; class Car { private: int YearModel; int Speed; string Make; public: Car(int, string, int); string getMake(); int getModel(); int getSpeed(); void Accelerate(); void … Re: Car Class with constructors and accessors Programming Software Development by necrolin class.function() So it's: first.Accelerate(); Re: Car Class with constructors and accessors Programming Software Development by mrnutty It alls here : [code] { switch (choice) { case 'a': case 'A': cout << "You are accelerating the car. "; cout << Accelerate(first) << endl; break; case 'b': case 'B': cout << "You have choosen to push the brake."; cout << Brake(first) << endl; break; } }… Re: Car Class with constructors and accessors Programming Software Development by mandofl Ok, let me try the advice to fix the errors. and that bracket i thought it was something more serious. I totally didn't catch that. As far as the original question in my first post, does this program answer that, or should i modify it so that it runs by itself without the user selecting a choice. Re: Car Class with constructors and accessors Programming Software Development by necrolin Well, doing a little extra work on an assignment is almost always a good thing. On the other hand the assignment specifies: [quote]Demonstrate the class in a program that creates a Car object and then calls the accelerate function five times. [/quote] You're solution doesn't do this so you could possibly lose marks. Make sure you read the … Re: Car Class with constructors and accessors Programming Software Development by mandofl Thanks that helps, I should of asked first before doing the program, but its ok, this was fun. Re: Car Class with constructors and accessors Programming Software Development by necrolin You're program is fine. Just run a loop to run accelerate 5 times before showing your menu. inheritance, polymorphism, and virtual functions Programming Software Development by jdpjtp910 …for max. # of passengers (int) constructor accessors and mutators. A print function that overrides the …for cargo capcity in tonnage (int) constructon, accessors, and mutators. print function that overrides the…string y) { name = n; year = y; } //Accessors string getName() {return name;} string getyear() {return year;} //… Inheritance homework problem Programming Software Development by smachee …built (a string). • A constructor and appropriate accessors and mutators. • A toString method that displays the… passengers (an int). • A constructor and appropriate accessors and mutators. • A toString method that overrides the…tonnage (an int). • A constructor and appropriate accessors and mutators. • A toString method that overrides the… Confusion on where to start interface project Programming Software Development by atticusMom … toString that includes all the subunits o getters (accessors) for name and population • Simple political unit …) o equals another object o toString o getters (accessors) for name and population • Composite political unit class… toString that includes all the subunits o getters (accessors) for name and population • Collection of political … Controlled Break help please Programming Software Development by ThomasNeedsHelp …public void setRate(){ this.getEmpRec(); this.payRate = payRate; } //Accessors public EmployeeRecord getEmpRec() { return new EmployeeRecord(this.empRec); } public … this.empRec.gross = this.numPieces * this.payPerPiece; } //Accessors public EmployeeRecord getEmpRec() { return new EmployeeRecord(this.empRec); } //… Stack Overflow Error Programming Software Development by SMITA6076 ….state = state; this.zipCode = zipCode; } /*** Accessors ***/ public String getName() { return name; } public …= getSmallBoxes( order.bagsOrdered ); dateOrdered = getDate(); } /*** Accessors ***/ public int getBagsOrdered() { return order.bagsOrdered; } public… GUI Issue Programming Software Development by SMITA6076 …smallBoxes = getSmallBoxes( bagsOrdered ); dateOrdered = getDate(); } /*** Accessors ***/ public int getBagsOrdered() { return bagsOrdered; } public int …Instantiates Order ***/ Order order = new Order( 0 ); /*** Accessors ***/ public double getCoffeeCost( int bagsOrdered ) { double coffeeCost =… why am i getting this error Programming Software Development by tyczj … node // Operators BST_Node& operator= (BST_Node& node); // Assignment // Accessors Key getKey() {return key;}; // get Key Data BST_Node* getLeft() {return… tree // Operators BST& operator= (BST& bst); // Assignment // Accessors int getSize() {return size;}; // returns number of elements in tree… What is the use of accessor?? Programming Software Development by bencwai … Order { private: vector<OrderItem> items; public: // Constructor Order() {} // accessors OrderItem operator[](int index) const { return items[index]; } // mutators [COLOR…]operator[](int index) { return items[index]; } in this programme the accessors seems useless,and what is the use of the operator…