Jump to content

Functions and classes explained


_Seb1

3 posts in this topic

Recommended Posts

Posted

So in this information thread I will explain what a Class is and what they are used for. Before I can explain what a Class is I must explain Functions and their usage.

The idea behind Functions that the code should be executed multiple times, so it gets outsorced to a Function. Such Functions can be called randomly in the program and if that happens all the Instructions in the function will be executed. The usage of Functions are not only to prevent code doubles. They can be  appointed very flexibal

- While calling the Function up, your able to send Data into it.

- After the Function has ended you can return Data to its calling place.

as example we will take an easy math function:

f(x) = x²

this function can be called with different Parametres and always computes the square of it. When it gets called up with the parametre 2 it delivers 4 as result.

They are able to work more than a math function though:

- the quantity of the parametres aren‘t limited. You can use many parametres.

- The Datatypes(Int, Float/Double etc other thread) are free choosable so you can use strings or booleans too.

- You can return values to its access point.

How is a Function made?

 

Name

Parametres

Return type

Functionstrunk

Must not be like this, but as C++ is very strict about that, you will need to write all that.

Example for a function:

Return Type Functionname(List_of_Parametres)

{(start of the functionstrunk aka Codeblock)

Instruction1;

Instruction2;

....

}

If a Function should not return Data the special return type void is used.

The list of parametres is a seperated list of Datatype-Name-Pairs.(int alpha, string beta)

The return instrction

The return instruction ends the function and gives the data back to its calling place. example the function f(x) = x²:

int f(int x)

{

  int y;

  y = x * x;

  return y;

}

That above is Pseudocode, you can realize it like that but there are parts missing(like defining x).

It is possible to use more than one return instruction. So as example:

int max(int x, int y)

{

 if (x > y)

    return x;

  return y;

}

It checks if x is bigger than y if thats true it gives back the data to its calling place and ends the function. If it is not true it returns y to the calling place and the function ends here.

Failures in the Function code

int max_failmao(int x, int y)

{

 if (x > y)

  return y;

}

👆wrong because there isnt a return instruction defined for x.

void failures

Void return type: Doesnt return values.

So

void Joka( )

{

 return 5;

}

👆failure

You can still use a return instruction in a void function to end it prematurely.

void WithJoka(int x)

{

if (x > 5)

 return;

}

 

Recursions.

Now because this is not used very often due to its high amount of storage eat, you won‘t face it very often.

int Recursionexample()

{

 return( ) + 1

would always call itself up again and add 1 to its parametres. This endlessrecursion would cause a crash of the program. Recursions are a very elegant way to solve problems but it takes muh storage due to its recalls.

 

Classes

What is a „Class“?

A class is an own datatype you can manage after your favor. In those classes objects(so called instances) are saved. So for the class „Human“ Seb, Tronald Dump etc. can be chosen as instances. Characteristic for classes is that all instances have the same skills(So called attributes: howtall; weight).  Every Instance in a class can perform actions: Like baking a cake(humans).

the skills of each instance can vary(not always the same weight).

You can simulate an own similar world with those classes.

How do you realize it in code?

3 parts:

The name

The skills

The actions

So in C++ a class is made like this:

(easy class)

class ClassnameJokaGay

{

..... Skills and actions .....

}

Actions are realized by functions in this actions are called methods of a class if you made it with functions. In the class you can access the skills(attributes)

Classes always have constructures, those methods are used to make new classinstances. Well now we know how to build a class, but what about a Constructor?

A Constructor is made like a function, having the same name like the class and without giving the return type.

ex.:

class score

{

....

   score( )

   {

     quantitygoalsteam1 = 0;

     quantitygoalsteam2 = 0;

   }

}

So because they are playing and they could shoot some goals we need methods to realize that class.

so ex.:

class score

{

 ....

 void goalsteam1( )

{

 quantitygoalsteam1 = quantitygoalsteam1 + 1;

}

Adds a goal to the team

void goalsteam2( )

 {

  quantityofgoalsteam2 =     quantityofgoalsteam2 + 1;

 }

}

So this was now long enough. If I have time I will create one about how to create instances and use them.

 

 

 

Archived

This topic is now archived and is closed to further replies.

  • Our picks

    • Hungry Shark Evolution v13.1.0 [ +9 Cheats ] Never Die
      Modded/Hacked App: Hungry Shark Evolution By Ubisoft
      Bundle ID: com.fgol.HungrySharkEvolution
      iTunes Store Link: https://apps.apple.com/us/app/hungry-shark-evolution/id535500008?uo=4



      Hack Features:

      - ADS NO

      - Gems Unlimited 

      - Coins Unlimited 

      - Health [ Auto Drain OFF ]

      - Booster Freeze 

      - Speed Hack 

      - Wall Break [ Only For Small Shark ]

      - Score Multi 

      - Invincible [ After Respawn ] Never Die
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 74 replies
    • Hungry Dragon by Hungry Shark v5.5.1 [ +7 Cheats ] Currency Max
      Modded/Hacked App: Hungry Dragon By Ubisoft
      Bundle ID: com.ubisoft.hungrydragon
      iTunes Store Link: https://apps.apple.com/us/app/hungry-dragon/id1163163344?uo=4

      Hack Features:
      - Currency Max
      - ADS NO 
      - Pet Unlocked 
      - Revive Cost 0
      - EAT Radius 
      - Booster Max 
      - Life [ Auto Drain OFF ]
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 17 replies
    • Hungry Dragon: by Hungry Shark v5.5.1 [ +7 Jailed ] Currency Max
      Modded/Hacked App: Hungry Dragon: by Hungry Shark By Ubisoft
      Bundle ID: com.ubisoft.hungrydragon
      iTunes Store Link: https://apps.apple.com/us/app/hungry-dragon-by-hungry-shark/id1163163344?uo=4

      Hack Features:

      - Currency Unlimited
      - NO ADS
      - Pet Unlocked
      - Revive Cost 0
      - EAT Radius
      - Booster Max
      - HP [ Auto Drain OFF ]
        • Informative
        • Agree
        • Thanks
        • Winner
        • Like
      • 13 replies
    • CarX Highway Racing v1.75.6 [ +6 Jailed ] Easy Win
      Modded/Hacked App: CarX Highway Racing By KAR IKS TEKHNOLODZHIS, OOO
      Bundle ID: com.CarXTech.highWayRacing
      iTunes Store Link: https://apps.apple.com/us/app/carx-highway-racing/id1236730191?uo=4


      Hack Features:

      - Auto ADS Disable

      - Mechanic Max

      - Police NO

      - Traffic NO

      - Rivals NO

      - Easy Drive Always
        • Informative
        • Agree
        • Haha
        • Winner
        • Like
      • 13 replies
    • CarX Highway Racing v1.75.6 [ +6 Cheats ] Easy Win
      Modded/Hacked App: CarX Highway Racing By KAR IKS TEKHNOLODZHIS, OOO
      Bundle ID: com.CarXTech.highWayRacing
      iTunes Store Link: https://apps.apple.com/us/app/carx-highway-racing/id1236730191?uo=4

      Hack Features:
      - Auto ADS Disable

      - Mechanic Max

      - Police NO

      - Traffic NO

      - Rivals NO

      - Easy Drive Always
        • Agree
        • Haha
        • Like
      • 8 replies
    • Dream Master-Travel Puzzle  v3.80 [ +5 Cheats ] Auto Win
      Modded/Hacked App: Dream Master-Travel Puzzle By F.O.G LIMITED
      Bundle ID: com.match.busters.free.ios
      iTunes Store Link: https://apps.apple.com/us/app/dream-master-travel-puzzle/id6636480682?uo=4


      🤩 Hack Features

      - Auto Win

      - Coins [ Disable After Hack ]

      - Stars [ Disable After Hack ]

      - Lives 0 Play Unlimited

      - Booster


      🍏 For Non-Jailbroken & No Jailbreak required hacks: https://iosgods.com/forum/79-no-jailbreak-section/
      🤖 Modded Android APKs: https://iosgods.com/forum/68-android-section/
        • Thanks
      • 12 replies
    • Dream Master-Travel Puzzle  v3.80 [ +5 Jailed ] Auto Win
      Modded/Hacked App: Dream Master-Travel Puzzle By F.O.G LIMITED
      Bundle ID: com.match.busters.free.ios
      iTunes Store Link: https://apps.apple.com/us/app/dream-master-travel-puzzle/id6636480682?uo=4

       

      🤩 Hack Features

      - Auto Win

      - Coins [ Disable After Hack ]

      - Stars [ Disable After Hack ]

      - Lives 0 Play Unlimited

      - Booster


      🍏 Jailbreak iOS hacks: https://iosgods.com/forum/5-game-cheats-hack-requests/
      🤖 Modded Android APKs: https://iosgods.com/forum/68-android-section/

       

      ⬇️ iOS Hack Download IPA Link


      Hidden Content

      Download via the iOSGods App
        • Winner
        • Like
      • 15 replies
    • Stick Cricket Clash v2.1.3 [ +3 Jailed ] Currency Freeze
      Modded/Hacked App: Stick Cricket Clash By Stick Sports Ltd
      Bundle ID: com.sticksports.stickcricketclash
      iTunes Store Link: https://apps.apple.com/us/app/stick-cricket-clash/id6444344271?uo=4


      Hack Features:
      - Currency Freeze
      - Score [ Win All Match ]
      - Ads Reward 


      Jailbreak required hack(s): https://iosgods.com/forum/5-game-cheats-hack-requests/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Haha
        • Winner
        • Like
      • 23 replies
    • Stick Cricket Clash v2.1.3 [ +3 Cheats ] Currency Freeze
      Modded/Hacked App: Stick Cricket Clash By Stick Sports Ltd
      Bundle ID: com.sticksports.stickcricketclash
      iTunes Store Link: https://apps.apple.com/us/app/stick-cricket-clash/id6444344271?uo=4



      Hack Features:
      - Currency Freeze
      - Score Win All Match
      - Ads Reward 



      Non-Jailbroken & No Jailbreak required hack(s): https://iosgods.com/forum/79-no-jailbreak-section/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Informative
        • Agree
        • Thanks
        • Winner
        • Like
      • 45 replies
    • Poker Hero - Joker Legend v1.8.9 [ +6 Cheats ] Easy Win
      Modded/Hacked App: Poker Hero - Joker Legend By Gemini Network
      Bundle ID: com.gemini.dash.deck
      iTunes Store Link: https://apps.apple.com/us/app/poker-hero-joker-legend/id6498983199?uo=4


      Hack Features:
      - Energy Freeze 

      - ATK Power [ Choose 1 Card Only Win Battle ]

      - Spell Power 

      - Always FullHouse [ Select Any Cards ]

      - Always Flush [ Select Any Cards ]

      - Always Straight [ Select Any Cards ]


      Non-Jailbroken & No Jailbreak required hack(s): https://iosgods.com/forum/79-no-jailbreak-section/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 73 replies
    • Poker Hero - Joker Legend v1.8.9 [ +6 Jailed ] Easy Win
      Modded/Hacked App: Poker Hero - Joker Legend By Gemini Network
      Bundle ID: com.gemini.dash.deck
      iTunes Store Link: https://apps.apple.com/us/app/poker-hero-joker-legend/id6498983199?uo=4



      Hack Features:

      - Energy Freeze 

      - ATK Power [ Choose 1 Card Only Win Battle ]

      - Spell Power 

      - Always FullHouse [ Select Any Cards ]

      - Always Flush [ Select Any Cards ]

      - Always Straight [ Select Any Cards ]


      Jailbreak required hack(s): https://iosgods.com/forum/5-game-cheats-hack-requests/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Informative
        • Haha
        • Winner
        • Like
      • 39 replies
    • Idle Nuns Tycoon v1.0.9 [ +4 Cheats ] Currency Max
      Modded/Hacked App: Idle Nuns Tycoon By SAMZU LIMITED
      Bundle ID: com.idle.nums.empire.tycoon
      App Store Link: https://apps.apple.com/us/app/idle-nuns-tycoon/id6747325865?uo=4
       

      🤩 Hack Features

      - ADS NO [ Rewards Free ]
      - Gold [ Disable After Get ]
      - Money [ Disable After Get ]
      - Silver [ Disable After Get ] Don't Use When Earn [ LVL & EXP ] Because Linked LvL & EXP Not Work
        • Agree
        • Winner
        • Like
      • 4 replies
×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines