Question about Computers & Internet

1 Answer

I don?t understand the use of pointers in C++

Posted by on

Ad

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    MVP:

    An expert that got 5 achievements.

    Governor:

    An expert whose answer got voted for 20 times.

    Scholar:

    An expert who has written 20 answers of more than 400 characters.

  • Expert
  • 78 Answers

Pointers are variables which store memory address of other variables.
It is denoted by an astrix *
Pointers and normal variables must have same data types.
Need of Pointers:
As said pointers variables store memory addresses of other variables, this can be used when we want to perform some calculations on a variable, we pass the address of this variable to the function from using pointers, thus any changes made to the variable will directly affect the variable as it is pointed to the same memory location.
It can also be for pointing various memory locations e.g. video memory. In the days of Dos we could actually read and write directly on to the video memory using address 0xB8000000 hexa decimal address.
Declaring a pointer:
int a = 10;
int *p = &a;
Here are passing address of a to p. Make sure that the data types should be same.
When we use pointers as arrays, it is much faster then the usual array iterators.
int num[] = {43,52,54,53};
int i=0, *j;
j=&num[0];
while(i<=3) { cout<<"num ["<<i<<"] = "<<*j<<endl; j++; } // This peice of code is faster than following method
for (int i=0;i<=3;++) { cout<<"num ["<<i<<"] = "<<num[i]<<endl; }
As we are directly working on memory.
Pointers are most commonly used to allocate memory dynamically, using new operator.
int *p = new [10];
This code allocates for 10 integer type array dynamically.
Dont forget to release the reserved memory using new operator by delete operator.
delete []p; // Frees the reserved memory.
This is an overview of pointers, as it requires study and practice.
Please rate. Thanks :)

Posted on May 09, 2010

Testimonial: "The explanation given by TapsCompWiz is quite clear and has made me understand the concept of pointers in C++ thoroughly. Thanks a lot TapsCompWiz"

  • TapsCompWiz May 09, 2010

    new operator allocates memory and delete operator frees that memory. It your responsibility to free the reserved memory in C++

×

Ad

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
goodluck!

Posted on Jan 02, 2017

Ad

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

How does it work


1. Begin with all timer segments on the dial 'pushed up'.
2. Push 'down' the segments required for the 'ON' time;
each segments represents 1/2 hour interval.
3. Rotate the dial clockwise until the 'TIME NOW' aligns with the pointer.
work-nya1amdyaj2mki0heak0qw2r-5-2.jpg

Mar 02, 2015 | Woods 59200 Lamp and Appliance Timer with...

Tip

About Laserpointer


Green laser pointers are fully legal for laser pointer use in most countries and at just below the maximum allowable legal power limit of 5mw for a pointer in most countries. We ensure that every high power green laser pointer is hand calibrated and tested to output at least 4.99mw and thus offers the expected stunning power expected of a real constant wave green (532nm) laser pointer, much brighter to look at than a regular red laser pointer and always with a visible green beam.
This high power green laser pointer will impress your coworkers, family and friends. Use it for your next presentation and everybody will know that you are ahead of the latest technology.
METAL BODY

This high power green laser pointer features a top precision all-metal body. Don't be fooled, some green laser pointers have a plastic body that is metalized. Our all-metal body green laser pointer is therefore robust and durable.

HIGH-QUALITY OPTICS

Our high power green laser pointer features an all-glass lens that focuses the beam to a sharper, rounder, clearer dot.

BRILLIANTLY BRIGHT

Powered by a Sony diode with a lifetime of 3000-5000 hours, it projects a high power green dot up to an incredible 2 miles away. And it so powerful that the beam itself can be seen for several hundred feet in darkness. That's why astronomers use it to point out constellations and stars in the night sky, the US Army uses it for training exercises, and executives at all levels use it to enhance their prestige. It's a very important tool if you get lost while hiking.


http://www.onlinelaserjp.com/green-laser.html

on Feb 02, 2015 | Hama Laserpointer Lp-8 4In1

1 Answer

Engine timing mark on pulley location where is it rotor is at #1 no notch in pulley near by.


Pull the number 1 spark plug out and see if the piston is right up at top of cylinder. Stick a pencil or something in there and feel for the top of the piston. If the distributor is seated right and rotor is pointed to number 1. piston should be at or very near top dead center of compression stroke. If it's not there, turn the crankshaft clockwise with a socket wrench till the piston on number 1 is at top. Whether you are on the compression stroke or the exhaust stroke of the piston, the notch on the pulley (if it has one) should be right on the zero degrees mark on the scale or pointer.
Post back if you still need help or don't understand something.. For timing, always find the compression stroke of number 1.

Jun 04, 2012 | Cadillac DeVille Cars & Trucks

1 Answer

Need to adjust timming on 91 ford mustang


pull the spout connector (a grey jumper located in the engine wiring harness either near the code reader port or the distributor) and put a timing light on the #1 spark plug wire. Aim the light at the pointer near the 10-o'clock position on the harmonic balancer (looking aft) while the engine is running and rotate the distributor until you see the pointer aiming at 8-10* BTDC. Don't forget to put the spout connector back in when you're done or else the computer won't be able to automatically advance the timing.

Nov 22, 2011 | 1991 Ford Mustang

1 Answer

I want my monitor to work once again because it says cannot display video mode? i dont understand help me?


You didn't say which OS you're running. However, it looks like you need to restart your computer in safe mode. This URL explains how to get in safe mode. When the computer boots the video it will look a bit grainy and you won't be able to see the entire desktop without using the scroll bars.

Both XP and Vista don't allow you to perform such an operation through the regular procedure and, as a result, you will only be able to get a screen resolution of 800×600 with the consequence that some icons and programs won't be displayed correctly. This is because Safe Mode just loads only basic services and drivers which are strictly necessary for Windows to run.

Fortunately, by employing the following techniques, you can get around this restriction permitting you to get whatever screen resolution you want.

Windows XP:
  1. Right click on your desktop.
  2. Click Properties.
  3. Click the Settings tab.
  4. Under Screen Resolution, drag the pointer to the right (where higher resolutions are located).
  5. Click Advanced.
  6. On the new window click OK, without modifying anything.
  7. Done, you should have successfully changed the resolution settings.
Windows Vista:
  1. Right click on your desktop.
  2. Click Personalize.
  3. Click Display Settings.
  4. Under Resolution, drag the pointer to the right (where higher resolutions are located).
  5. Click Advanced Settings.
  6. On the new window click OK, without modifying anything.
  7. Done, you should have successfully change the resolution settings.

Aug 11, 2011 | Dell 1503FP 15" LCD Monitor

1 Answer

When I turn the timer dial, I can't see where the mark is to line up the dial with the time on the dial. For example, I want the timer to start the fountain at 7:00 am. I can clearly see the 7:00 am on...


You posted under Intermatic timer, but don't say which one.
Most dial timers have a stationary silver pointer. Rotate dial until current time lines up with stationary silver pointer.

T100 series pointer is stationary at 6:00
T88 and other sprinkler timers, the pointer is about 6:45
WH40 timer is 6:00
If you have plug-in timer, the arrowhead pointer is usually located on inner dial, other plug-in timers can vary a bit.
http://waterheatertimer.org/Intermatic-trippers-and-parts.html#T100
http://waterheatertimer.org/Boxtype.html
http://waterheatertimer.org/images/WH40-001-300.jpg
http://waterheatertimer.org/images/Woods-59419-image-500.jpg

Tork and Paragon timers are different.

Add a comment for more free help, and include exact timer brand and model number that shows on inside of timer door.

Also take advantage of fixya expert assistance live.
For a price, expert works with you while you work on timer or any do-it-yourself project.
Fixya is always less expensive than a service call.

Apr 25, 2011 | Intermatic & Indoor/Outdoor Rain Tight...

1 Answer

We can't find the cursor anymore?


you might have to uninstall the mouse then restart your computer then reinstall the mouse and its drivers
make sure the battery is good (has full charge)also you might test the usb device for the mouse is inserted correctly into the usb port (if applicable)
click start control panel mouse you should see 4 tabs buttons,pointers,pointer options and hardware under hardware you can troubleshoot also you can select properties under driver you will have options to update driver,rollback driver or uninstall and under hardware you can troubleshoot
in xp
hope this helps
don

Feb 12, 2011 | Logitech Cordless Mouse

1 Answer

How to write a record with pointer variables in a file in c++


if understand your question correctly , you don not work the pointer value but the contents the pointer is referring to.

Hope that makes sense

char* pointer = "some message";

pointer = 0x04556 *pointer = "s";

Regards
GeWiz

Apr 13, 2009 | Intel Computers & Internet

Not finding what you are looking for?
Computers & Internet Logo

Related Topics:

92 people viewed this question

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

Doctor PC
Doctor PC

Level 3 Expert

7733 Answers

kakima

Level 3 Expert

102366 Answers

David Payne
David Payne

Level 3 Expert

14161 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...