Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 06-24-2002, 06:16 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
pointers ..

re: cpp

i read a little about pointers last night .. is the whole idea and reason to use pointers for accessing local variable and member variables after they have been destroyed? i still don' t get it.
sde is offline   Reply With Quote
Old 06-24-2002, 12:24 PM   #2 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 285
technobard is on a distinguished road
In general, pointers are good for those occasions when you want to pass the address of an object (so that the object can be modified or called directly) rather than the value of an object. I used them in C. I never did much with C++. Back when I was playing with Turbo C for DOS, it was also faster to use pointers to memory addresses (like video memory, for example). It probably still is, but I suspect it's a lot less noticeable.

Pointers to functions was also popular. The idea is that you would store an array (or other data structure) of pointers, each pointing to some function. You could access those functions simply by accessing different elements of the array. It makes for compact code, although it isn't (my opinion) as easy to follow the logic.

The most common C or C++ error involves bad pointer arithmetic, so watch out!
technobard is offline   Reply With Quote
Old 06-24-2002, 12:54 PM   #3 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,696
redhead is on a distinguished road
And using pointers saves on memory usage. Instead of copying the structure, when given as an argument to a function, you pass the pointer to that structure.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
far or near iwanttolearnc Standard C, C++ 2 06-15-2004 09:28 PM
A day late and pointers short saline Standard C, C++ 2 10-04-2003 10:33 AM
Pointers w00t Standard C, C++ 14 03-02-2003 12:15 PM
What does void do? w00t Standard C, C++ 11 08-22-2002 07:26 AM


All times are GMT -8. The time now is 11:30 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting