From what I understand of classes is that they function similarly to SC2 libraries, in that they contain their own list of functions and variables. Is this how classes work in C++ or am I understanding it wrong?
Yeah, thats about right. Actually they are pretty close to records of the trigger editor, meaning that you have to create instances of a class first in order to actually use it (with the exception of static functions & variables, but that's a little too far here). You can create public functions and variables that you can use outside of the class/its instances and private ones that can only be used from within an instance (like an internal counter for example). Apart from that you can also derive classes. The derived classes can use all non-private functions/variables of its base class, along with those that are declared protected.
A class is an object project.
This object has many properties, called variables.
This object can also do many actions, called methods.
Some methods and variables can be seen from outside, they are called public methods and variables.
Some cannot, they are called private methods and variables.
A method is like a function, and a variable is still a variable, like the one you use normally also in the galaxy editor.
Since it is a function, a method can use parameters and return values. Some method are used, for example, to set or get the value of private variables from the outside of the class.
The outside of the class is the rest of the world, in a simple example an int main().
You can define variables using a class, passing values or variables as parameter to an "inizialization" method, called constructor.
Once a class is deleted, it invokes an other method, the so called destructor.
To clarify, a small example:
header.hpp:classrectangle:{private:// Variables definitionintx;inty;intheight;intwidth;public:// Methods definition: in order -> constructor, setter and getterrectangle(inth,intw,intpos_x=0,intpos_y=0);voidsetHeight(inth);intgetWidth();};source.cpp:#include <header.hpp>// Constructor declarationrectangle::rectangle(inth,intw,intpos_x,intpos_y){x=pos_x;y=pos_y;height=h;width=w;}voidrectangle::setHeight(inth){height=h;}intrectangle::getWidth(){returnwidth;}
I think, methods aside, its easer to liken it to the data editor. Lets take units as an example. You have unit types and units themselves; unit types define the characteristics of what an ingame unit should be like, while each ingame unit is an already existing entity, defined by the unit type. For c, the unit type would be called a class, and the ingame units be instances.
You have a unit type called "Marine", which has properties like HP, Energy, armor, etc. These would be called attributes in c. An unit can have actions (like say, attack, die, move, etc), which would be called methods.
I have to go so i cant finish this post, but try ti figure out the rest ahah
int and float are primitives, not classes tho (well, they are in c, java is more... complicated; and l;ets not get into javascript)
You're right, I was thinking of java where I pratically always use Integer in place of int :P
However I think the galaxy editor Integer and Real are actually classes...
Rollback Post to RevisionRollBack
Battle.net wants to call me InsaneMst, Insane... but you should call me InsaneMonster!
So pretty much the data editors types are classes?
Yes, but they are more strict. Although under the hood there are classes, they are also fairly immutable, you notice that values are static, they can not take functions (I can't put a damage effect value to be some combination of other values). This is called Data Oriented Design.
So pretty much the data editors types are classes?
Yes, but they are more strict. Although under the hood there are classes, they are also fairly immutable, you notice that values are static, they can not take functions (I can't put a damage effect value to be some combination of other values). This is called Data Oriented Design.
From what I understand of classes is that they function similarly to SC2 libraries, in that they contain their own list of functions and variables. Is this how classes work in C
++
or am I understanding it wrong?Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
Yeah, thats about right. Actually they are pretty close to records of the trigger editor, meaning that you have to create instances of a class first in order to actually use it (with the exception of static functions & variables, but that's a little too far here). You can create public functions and variables that you can use outside of the class/its instances and private ones that can only be used from within an instance (like an internal counter for example). Apart from that you can also derive classes. The derived classes can use all non-private functions/variables of its base class, along with those that are declared protected.
A class is an object project. This object has many properties, called variables. This object can also do many actions, called methods.
Some methods and variables can be seen from outside, they are called public methods and variables. Some cannot, they are called private methods and variables.
A method is like a function, and a variable is still a variable, like the one you use normally also in the galaxy editor. Since it is a function, a method can use parameters and return values. Some method are used, for example, to set or get the value of private variables from the outside of the class.
The outside of the class is the rest of the world, in a simple example an int main(). You can define variables using a class, passing values or variables as parameter to an "inizialization" method, called constructor. Once a class is deleted, it invokes an other method, the so called destructor.
To clarify, a small example:
Battle.net wants to call me InsaneMst, Insane... but you should call me InsaneMonster!
Author of InsaneAI library, InsaneCredits library, InsaneDebug library, InsaneTransmission library, InsaneUI library and InsaneBriefing library.
Author of Mercenary Business - Top 10 Rock The Cabinet 2017: Co-op edition.
I think, methods aside, its easer to liken it to the data editor. Lets take units as an example. You have unit types and units themselves; unit types define the characteristics of what an ingame unit should be like, while each ingame unit is an already existing entity, defined by the unit type. For c, the unit type would be called a class, and the ingame units be instances.
You have a unit type called "Marine", which has properties like HP, Energy, armor, etc. These would be called attributes in c. An unit can have actions (like say, attack, die, move, etc), which would be called methods.
I have to go so i cant finish this post, but try ti figure out the rest ahah
Go play Antioch Chronicles Remastered!
Also, coming soon, Antioch Episode 3: Thoughts in Chaos!
Dont like mapster's ugly white? Try Mapster's Classic Skin!
Thank you all for the info
So pretty much the data editors types are classes?
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
I think we can guess that the editor itself is a class, like pretty much everything within.
Pretty much the entire game I dare to assume... ;)
Yes of course the unit types are classes, they are like int, float, or rectangle.
Battle.net wants to call me InsaneMst, Insane... but you should call me InsaneMonster!
Author of InsaneAI library, InsaneCredits library, InsaneDebug library, InsaneTransmission library, InsaneUI library and InsaneBriefing library.
Author of Mercenary Business - Top 10 Rock The Cabinet 2017: Co-op edition.
int and float are primitives, not classes tho (well, they are in c, java is more... complicated; and l;ets not get into javascript)
Go play Antioch Chronicles Remastered!
Also, coming soon, Antioch Episode 3: Thoughts in Chaos!
Dont like mapster's ugly white? Try Mapster's Classic Skin!
You're right, I was thinking of java where I pratically always use Integer in place of int :P However I think the galaxy editor Integer and Real are actually classes...
Battle.net wants to call me InsaneMst, Insane... but you should call me InsaneMonster!
Author of InsaneAI library, InsaneCredits library, InsaneDebug library, InsaneTransmission library, InsaneUI library and InsaneBriefing library.
Author of Mercenary Business - Top 10 Rock The Cabinet 2017: Co-op edition.
Nope, primitives there too.
Go play Antioch Chronicles Remastered!
Also, coming soon, Antioch Episode 3: Thoughts in Chaos!
Dont like mapster's ugly white? Try Mapster's Classic Skin!
Yes, but they are more strict. Although under the hood there are classes, they are also fairly immutable, you notice that values are static, they can not take functions (I can't put a damage effect value to be some combination of other values). This is called Data Oriented Design.
Yes, but they are more strict. Although under the hood there are classes, they are also fairly immutable, you notice that values are static, they can not take functions (I can't put a damage effect value to be some combination of other values). This is called Data Oriented Design.
@willuwontu: Go
Wow, I feel so old.. its been over 10 years since my last college C class.
https://www.amazon.com/Starting-Out-Early-Objects-7th/dp/0136077749/ref=cm_cr_arp_d_product_top?ie=UTF8
This is the old book I used for learning C. Around page 650 are some good explanations about classes.