Jump to content
Sign in to follow this  
  • entries
    68
  • comments
    57
  • views
    42224

Long day.

Sign in to follow this  
RanBlade

201 views

Well work is tiring but I have started taking my C++ books to work and reading them on breaks. I have gotten to understand pointers a lot better which Iam glad for because i remember reading somewhere that passing pointers to functions instead of the actual type is faster cus it transfers 1byte instead of 4(for a int). Iam going to try and find that again and clarify it.

Anyway work goes as normal on Engine. slow until works over but Iam trying to get some done. Still havent had time to actually tackle the coding of my event system. thinking about how exactly i want to do it. I think iam going to read through all of the SDL docs for events this weekend and then go from there. well take it easy eveyrone
Sign in to follow this  


1 Comment


Recommended Comments

Not quite. A pointer should be 32 bits, and therefore 4 bytes. (On a 32 bit system. 64 bits on a 64 bit system.) The reason it's better to pass by pointers is that you won't make a copy of the entire object. This is great if you have a big struct or class. Here's an example:


#include <stdio.h>

struct BigStruct
{
int foobar[2000];
};

int main()
{
printf("%d\n", sizeof(int*));
printf("%d\n", sizeof(BigStruct));
printf("%d\n", sizeof(BigStruct*));
return 0;
}


Output:
4
8000
4

In C++, instead of passing by pointers, you'll probably want to use references.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 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!