Jump to content
Sign in to follow this  
Debbie

Pointer C++

Recommended Posts

ader ke pointer yg salah atau betul? umumnya, pointer dalam programming biasanya samada null atau non-null. Basically dalam kod, awak test pointer samada ia null atau tidak. Contohnya :

if (somePointer = NULL) {
  //error
} else {
  //do something with somePointer 
}
Biasanya boolean false diwakili oleh 0 dan boolean true diwakili oleh non-zero value... basically the same mcm pointer.. so kiranya awak bolehlah test pointer awak salah ke betul .. Selalunya ada ringkasan yang digunakan. Contohnya dalam C/C++, kita taknak null pointer, so kita test pointer variable dengan if mcm ni
if (somePointer) {
  //pointer is valid, do something with it
}
lagi
if (!somePointer) {
   //pointer is invalid, error
}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...