Jump to content
  • Advertisement

Archived

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

Last Attacker

A few questions.

This topic is 6226 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

Hi, since Myopic Rhino is offering a moderator-job, I guess someone might answer a few of my questions to C++. 1. What is the function of the "*" in Char * str; ? 2. What does a pointer and a reference operator do (I think it might be "*" and "&")? 3. Do you access assebler code through "___asm{"? 4. Is the "?" a shorter "else" in an if-statement? Well I'm sorry I asked so much questions, I'm kinda new to C++ and I wanted to now those basic stuff. By the way, (if you're feeling up to that) what whould be the best way to write a Window-styled C++ app. (with VC++)? MFC or plain Win32 projects? Well thanks at least for reading! ----------=Last Attacker=---------- ICQ: 120585863 E-mail: laextr@icqmail.com Edited by - last attacker on July 2, 2001 5:36:53 PM

Share this post


Link to post
Share on other sites
Advertisement
So many questions!
Let's see...

"1. What is the function of the "*" in Char * str; ?"
In this context, the '*' means that the variable you are declaring will be a pointer, as opposed to an actual character. The pointer will store the address of a block of memory, and that block of memory will contain a bunch of char's.

"2. What does a pointer and a reference operator do (I think it might be "*" and "&")?"
In simplistic terms, the pointer operator '*' will give you the value of what a pointer points to, as opposed to the pointer itself. The reference operator will give you the address of a variable. Perhaps some code would demonstrate this better..
    
int n = 500;
int* i; // i is a pointer to an integer

i = &n; // now i points to the address of n

cout << i << endl; // this will output the memory address stored in i

cout << *i << endl; // this will output the value stored in the address that i holds



"3. Do you access assebler code through "___asm{" ?"
Yes. That's one way. You can also write your ASM separately and link to it.

"4.Is the "?" a shorter "else" in an if-statement?"
Not exactly.
   
if(a < b)
do_stuff();
else
do_other_stuff();

is equivalent to:
  
a < b ? do_stuff() : do_other_stuff();

It's generally not a good idea to use the '?' operator, as it can lead to unreadable code.

"5. How do you use macro's?"
You define a macro with the #define keyword, like so:
  
#define MyMacro(x) ((x * 2 + 5) << 1))

int i = MyMacro(3);


I hope all that was somewhat understandable and somewhat helpful

~~~~~~~~~~
Martee

Edited by - Martee on July 2, 2001 5:58:52 PM

Share this post


Link to post
Share on other sites

  • 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!