Thread: OO and U
View Single Post
Old 05-10-2010, 04:11 PM   #3
FlamesPuck12
First Line Centre
 
Join Date: Apr 2007
Exp:
Default

An example, copy and pasted from my notes. (Well not really, I just rewrote one on the spot)

Edit: This is in C++

//So class is like "struct" and the class name is Stats

class Stats {
public: //Anything below is public access, until the keyword private

int getGoals(); //These functions are methods
void setGoals(int x); //int, void are return types. Void doesn't return anything and since you're only using them to adjust member variables, you don't need a return value

int getAssists();
void setAssists(int x);

private:
int G; //These are private variables that only methods can access or adjust
int A;
};

int main() {
class Iginla;
Iginla.setGoals(50);
Iginla.setAssists(50);
}

Last edited by FlamesPuck12; 05-10-2010 at 04:15 PM.
FlamesPuck12 is offline   Reply With Quote
The Following User Says Thank You to FlamesPuck12 For This Useful Post: