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

    • Love & Pies - Merge Mystery +8 Jailed Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Love & Pies - Merge Mystery By Trailmix Ltd
      Bundle ID: com.Trailmix.LoveAndPiesMerge
      App Store Link: https://apps.apple.com/us/app/love-pies-merge-mystery/id1563239332?uo=4

       
       

      🤩 Hack Features

      - Unlimited Coins
      - Unlimited Gems
      - Unlimited Energy
      - Unlimited Stars
      - Complete Order
      - Complete All Orders
      - Clear Blockers
      - Unlock All Storage Slots
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 56 replies
    • Zombusters v3.3.2 [ +12 APK MOD ] Currency Max
      Mod APK Game Name: Zombusters
      Rooted Device: Not Required.
      Google Play Store Link: https://play.google.com/store/apps/details?id=com.lexenzolab.vs&hl=en

      🤩 Hack Features

      - Gems Freeze
      - Coin Freeze
      - Energy Freeze
      - Resources Freeze
      :::::: VIP ::::::
      - VIP Active
      - ADS NO / Rewards Free
      - Unlimited Gems
      - Unlimited Coins / Battle Drop / Patrol Rewards
      - Unlimited Energy
      - Unlimited Resources / Easy To Upgrade
      - HP MAX
      - ATK MAX
        • Like
      • 1 reply
    • Zombusters v3.3.2 [ +12 Cheats ] Currency Max
      Modded/Hacked App: Zombusters By VOILAGAMES LTD
      Bundle ID: com.lexenzolab.vs
      App Store Link: https://apps.apple.com/us/app/zombusters/id6747124932?uo=4

      🤩 Hack Features

      - Gems Freeze
      - Coin Freeze
      - Energy Freeze
      - Resources Freeze
      :::::: VIP ::::::
      - VIP Active
      - ADS NO / Rewards Free
      - Unlimited Gems
      - Unlimited Coins
      - Unlimited Energy
      - Unlimited Resources / Easy To Upgrade
      - HP MAX
      - ATK MAX
        • Informative
      • 1 reply
    • Zombusters v3.3.2 [ +12 Jailed ] Currency Max
      Modded/Hacked App: Zombusters By VOILAGAMES LTD
      Bundle ID: com.lexenzolab.vs
      App Store Link: https://apps.apple.com/us/app/zombusters/id6747124932?uo=4

      🤩 Hack Features

      - Gems Freeze
      - Coin Freeze
      - Energy Freeze
      - Resources Freeze
      :::::: VIP ::::::
      - VIP Active
      - ADS NO / Rewards Free
      - Unlimited Gems
      - Unlimited Coins
      - Unlimited Energy
      - Unlimited Resources / Easy To Upgrade
      - HP MAX
      - ATK MAX
        • Like
      • 0 replies
    • Word Champion PvP word battles v0.01 [ +7 APK MOD ] Auto Win
      Mod APK Game Name: Word Champions - Word Battles
      Rooted Device: Not Required.
      Google Play Store Link: https://play.google.com/store/apps/details?id=com.peoplefun.wordchamps

      🤩 Hack Features

      - Auto ADS NO
      - Auto Win
      - Merge Any Words
      - Unlimited Coins
      - Your Soccer Max 2000
      - AI Soccer 0
      - AI Can't Place Word
      • 0 replies
    • Path of Kings +32++ Jailed Cheats [ Debug Menu ]
      Modded/Hacked App: Path of Kings By Voodoo
      Bundle ID: com.TornadoBear.WayOfKings
      App Store Link: https://apps.apple.com/us/app/path-of-kings/id6753709030?uo=4

       


      🤩 Hack Features

      - Damage Multiplier
      - Defence Multiplier
      - God Mode
      - Debug Menu
        • Agree
        • Winner
        • Like
      • 1 reply
    • Word Champions - Word Battles v0.01 [ +7 Cheats ] Auto Win
      Modded/Hacked App: Word Champions - Word Battles By PeopleFun, Inc.
      Bundle ID: com.peoplefun.wordchamps
      App Store Link: https://apps.apple.com/us/app/word-champions-word-battles/id6779349143?uo=4

      🤩 Hack Features

      - Auto ADS NO
      - Auto Win
      - Merge Any Words
      - Unlimited Coins
      - Your Soccer Max 2000
      - AI Soccer 0
      - AI Can't Place Word
      • 1 reply
    • Word Champions - Word Battles v0.01 [ +7 Jailed ] Auto Win
      Modded/Hacked App: Word Champions - Word Battles By PeopleFun, Inc.
      Bundle ID: com.peoplefun.wordchamps
      App Store Link: https://apps.apple.com/us/app/word-champions-word-battles/id6779349143?uo=4

      🤩 Hack Features

      - Auto ADS NO
      - Auto Win
      - Merge Any Words
      - Unlimited Coins
      - Your Soccer Max 2000
      - AI Soccer 0
      - AI Can't Place Word
      • 0 replies
    • Dungeon Hunter 6 +1 Jailed Cheat [ Dumb Enemies ]
      Modded/Hacked App: Dungeon Hunter 6 By Goat Co. Ltd
      Bundle ID: com.goatgames.dhs.gb.ios
      App Store Link: https://apps.apple.com/us/app/dungeon-hunter-6/id1664335636?uo=4

       
       

      🤩 Hack Features

      - Dumb Enemies
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 68 replies
    • Idle Airplane Inc. Tycoon +1++ Jailed Cheat [ Unlimited Currencies ]
      Modded/Hacked App: Idle Airplane Inc. Tycoon By Green Panda Games
      Bundle ID: com.gpg.airplaneinc
      iTunes Store Link: https://apps.apple.com/us/app/idle-airplane-inc-tycoon/id6445961774
       

      Hack Features:
      - Unlimited Currencies -> Will increase instead of decrease.
      - Free In-App Purchases -> Toggle on via iGMenu.


      Jailbreak required hack(s): [Mod Menu Hack] Idle Airplane Inc. Tycoon ( All Versions ) +2++ Cheats [ Unlimited Currencies ] - Free Jailbroken Cydia Cheats - iOSGods
      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
        • Haha
        • Thanks
        • Winner
        • Like
      • 82 replies
    • Mini Golf Club PvP Multiplayer +20++ Jailed Cheats [ Debug Menu ]
      Modded/Hacked App: Mini Golf Club PvP Multiplayer By BoomBit, Inc.
      Bundle ID: mini.golf.sports.club.games
      App Store Link: https://apps.apple.com/us/app/mini-golf-club-pvp-multiplayer/id6741755675?uo=4

       


      🤩 Hack Features

      - Debug Menu -> Head into Settings and toggle the Music slider.

      Most features probably won't work, but features like auto win, set trophies do work however. 
        • Winner
        • Like
      • 12 replies
    • Mars Survivor - Loot & Build +7 Jailed Cheats [ Unlimited Everything ]
      Modded/Hacked App: Mars Survivor - Loot & Build By Estoty LLC
      Bundle ID: com.space.breaker.game
      iTunes Store Link: https://apps.apple.com/us/app/mars-survivor-loot-build/id6476778963?uo=4


      Hack Features:
      - Unlimited Currencies -> Earn some.
      - Unlimited Resources -> Earn some.
      - God Mode
      - One-Hit Kill
      - One-Hit w/ Tool
      - No Ads -> Head into Settings and toggle the Discord Support button. Game will crash, re-launch the game.


      Jailbreak required hack(s): [Mod Menu Hack] Mars Survivor - Loot & Build v1.1.5 +7 Cheats [ Unlimited Everything ] - Free Jailbroken Cydia Cheats - iOSGods
      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
        • Haha
        • Thanks
        • Winner
        • Like
      • 47 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