Advertisement

VB Vs. C++

Started by July 17, 2001 04:11 PM
27 comments, last by tenchimusakiryoko 23 years, 6 months ago
quote:

MyArray[10] is equivelent to

*(MyArray+10)


Ok, first up, no I am not very familiar with pointer notation, I understand the concepts fine, but the notation can take me a while to digest . I take it that *(MyArray + 10) is a pointer to 10 bytes after MyArray yes?

quote:

And *(10+MyArray) will either crash your program, or load or store unwanted data. (Assuming MyArray was declared MyArray[10])


Cool... unless I am completely stupid (I hope not ) then that supports what I said.

I think I might go and read some C tutes, just so I don''t make a total arse of myself any more.

Oh yeah, another downside to VB is the way it works with OpenGL. Although I haven''t used it, I''ve seen code which uses it, and it looks really messy. Some people use it and love it though, so it isn''t a total write off.
Trying is the first step towards failure.
quote:

Ok, first up, no I am not very familiar with pointer notation, I understand the concepts fine, but the notation can take me a while to digest . I take it that *(MyArray + 10) is a pointer to 10 bytes after MyArray yes?



Don''t mind me... I''ve just finished reading some stuff, and I see it isn''t necessarily 10 bytes
Trying is the first step towards failure.
Advertisement
Correct. MyArray + 10 will be the address of MyArray plus 10* the size of the type of MyArray. Don't worry, this stuff is not a necessity starting off, but, when you understand it all it really helps.

Also,

*(MyArray + 10) is the dereferenced address.

Usually, you would use MyArray as an array and go on your happy way. Like

int MyArray[5];
int MyInt;

MyInt = MyArray[0];


But, it's nice to know that MyArray just holds an address. If your array(assuming 2 bytes per int) is stored at bytes 1010, 1012, 1014, 1016 and 1018, then MyArray holds the value 1010. You cannot change this value. But you can change the value 'stored' at 1010. You must dereference the 'pointer' (or address) by going *MyArray. In declarations, * means you're declaring a pointer, while in other statements, it means 'dereference'. (or multiply :p)
Or instead of dereferencing, you could use the C shorthand MyArray[0]. MyArray[0] is the exact same as *MyArray in this situation. So,

MyInt = MyArray[0];
or
MyInt = *MyArray;

If MyArray is declared as an array, use the first one, for readabities sake. However, understand that MyArray is and address/pointer, that is the exact same as any other pointer, except that it is constant.

ie, this will not work,

MyArray = 1050;

Anyway, hope that's not too much to swallow, and I hope I didn't make any mistakes to confuse you. Have fun.





Edited by - Thrump on July 22, 2001 9:37:08 AM

Edited by - Thrump on July 22, 2001 9:38:21 AM

Edited by - Thrump on July 22, 2001 9:45:08 AM
Oh, btw, I''ve used openGL from VB, and I don''t think it''s messy at all. Just as messy as using it from C++ windowed apps.
Cool, thanks for helping me there... I''m willing to learn

In my research yesterday, I came across something saying that the negative version of the "++" is just a single "-"... and I don''t think that is right... hopefully that place got pointers right too, otherwise I''m in a bit of trouble

I suppose my biggest trouble is understanding the referencing/dereferencing type thing, because there is none of that in VB. But I''m not asking for any more crash courses , I''m sure I''m not the only one who has been put off by them.

Thanks a lot for helping me though, it really does help
Trying is the first step towards failure.
If you want to make a windows GUI program quickly, VB is of course going to be much easier. However, I find that coding slightly complicated algorithms and data structes is much easier in C++ than VB. Once I get around to figuring out how to put all my code in C++ DLLs called from a GUI made in VB, I''ll have the best of both worlds!
Advertisement
As fast as C++ is, i love VB. Making games is my hobby, VB does a perfect job at helping me out. With the use of DirectX8 some really neat things could be done in VB. Vb code is easy to understand, and it takes no time to do something. C++ will always be faster and harder! If you''re making games as a hobby, there''s nothing better than VB!
for all of you people using c++ : YOU SUCK! use pure assembler, it''s alot faster! VB is great though, in 2 minutes i can make something that would take me 2 hours in C++, and 2 days in ASM. So if you calculate the development time of a C++ game, and divide it by PI*SIN(PI)*20, you''ll get the time it would take VB to do the same game!

Once again Xorcist chimes in...

"Power, Simplicity, Speed... you just can''t go wrong with Delphi!"

{It''s everything you want out of C/C++ with the ease of VB}

This topic is closed to new replies.

Advertisement