Jump to content
  • Advertisement
Sign in to follow this  
somebodys_life

something to make this easier...

This topic is 4495 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i know there is something to make this easier i just can't remember what it is or how to do it. I have a series of functions that i need to be operated multiple times. (C++) So i put them into something similar to a class and i just call that class everytime i wish to perform that series of functions. I can't remember what this is or the general syntax. If anyone could give me a brief description and tell me what it is i am thinking of i would really appreciate it. thanks

Share this post


Link to post
Share on other sites
Advertisement
Why not just have all of your functions written out and then have one function that calls all the functions you want?

Share this post


Link to post
Share on other sites
It sounds like you a bit confused on terminology.

You don't "operate" functions. You call them. However, classes are templates for creating and using objects. You can't call classes.

Although from your post, it's not clear what you're trying to do, I'm going to guess you are trying to create a function to call several functions in succession. Here's how you would do that:


void FuncA()
{
...
}

void FuncB()
{
...
}

void FuncC()
{
}

void CallAllFuncs()
{
FuncA();
FuncB();
FuncC();
}

.... // later in your main or whereever

CallAllFuncs();


These functions can also take parameters and return values.

Share this post


Link to post
Share on other sites
ok another thing, i want to ad something to an int, and i can't get it to work properly..

its just,

if (blah){
+5 x;
}

and it won't work, i'm not sure if that is correct or not.

thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by somebodys_life
ok another thing, i want to ad something to an int, and i can't get it to work properly..

its just,

if (blah){
+5 x;
}

and it won't work, i'm not sure if that is correct or not.

thanks

what language are you using? that's definitely not a C derivative language.

Share this post


Link to post
Share on other sites

int A;

A = 7; // int 'A' now holds '7'

A += 5; // int 'A' is now '13'

A = A + 5; // int 'A' is now '18'

A -= 2; // int 'A' is now '16'

A = A - 2; // int 'A' is now '14'
_________________________________

int B;

B = 5; //Sets 'B' as five

B = A; //Sets 'B' to whatever 'A' is

B += A; //Adds 'A' to 'B'

B++; //Adds '1' to 'B'

B--; //Subtracts '1' from 'B'

B = B * B; //Multiplys 'B' times itself

A = B * B; //'A' now holds B sqared. (If 'B' is equal to '2', 'A' would now be '4' and 'B' would still be '2'



I think you want:


if(whatever)
{
x += 5;
}



But I can't be sure unless I know what luagage you are using. (i.e. C, C++, Java, et c...)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!