it can be true, depending on how you use them. For example if you pass a pointer to a class or function, you have ONLY passed that memory address to that class/function (and not copied the value in the variable which contains the data) which means that you have passed that variable much faster than if you were to use an actual non pointer variable or pass a variable by value.
Pointers are fast because they contain only memory addresses so the entire contents of the variable is not copied and passed which would be much slower.
Also to answer the second part of your question, yes in large programs memory handling can be difficult, pointers are active for the scope they are placed in (provided the programmer is linking to an object ONLY, and put a deconstructor into that object), put one at the start of your program and forget to delete it, well then now you have a major problem (a memory leak). I had a programmer friend that complained about his boss always saying, son its not your memory you need to stop pretending like it is, he was fresh out of college when he got that job, and his programming skill did increase when he got it.
Honestly though, it really does depend on the way you use them as well as the algorithm you go by.
2007-02-24 14:39:56
·
answer #1
·
answered by D 4
·
0⤊
0⤋
pointers unlike variables do not store the value. instead they store the memory address of the variable that stores value. when we want to get the value pointed by the pointer using *ptr then the system do not need to find the memory of the value since it is already stored by the pointer. this makes working fast. u said that execution speed increases which is true.
Also, u said that memory handling is difficult. either u have misunderstood the question is a problem. one of the solution to ur next question is that pointer deal with memory directly. so it is very difficult to debug( find error ) from a program using pointers. so this makes the program development slow and not program efficiency slow. this is other concept beyond programming and is studied in software engineering.
i think u have under stood the use of pointer. it has merit of fast execution but demerit of slow program development.
2007-02-24 16:24:59
·
answer #2
·
answered by Anonymous
·
0⤊
0⤋
Pointers don't magically increase or decrease anything. In some instances, pointers can be detrimental. So, what is a pointer? It's a variable that contains an address to a memory location. This is important: pointers are still variables. They take memory as well. If you're pointing to a char byte, using a pointer instead of a char isn't going to increase your efficiency, and may decrease it instead.
Pointers are useful when passing variables around in say, functions. What happens in C is that the variable is copied. So let's say you had a 100KB variable (like an array) in a struct. You don't want to pass that struct around by value, because your program would be forced to copy those 100KB. It's more efficient to refer to that memory location with a pointer, and then use that pointer to refer back to the value.
Note that you can shoot yourself in the foot with pointers. What happens if you have a memory location only known by its pointer, and then forget about the pointer (your pointer var goes out of scope, you accidentally assign another memory address, etc.)? You don't have a way to access the original memory location, and that memory sits around unused. Known as memory leaks.
2007-02-24 14:59:36
·
answer #3
·
answered by csanon 6
·
2⤊
0⤋
Yes, pointers increase the execution speed because it directly points to the location of a variable, the value can be retrieved and processed in a short span of time.
2007-02-24 14:55:12
·
answer #4
·
answered by ? 6
·
0⤊
1⤋
First, an #comprise fact is a preprocessor command. It basically provides, transformations and ignores specific issues in accordance to the instructions and how they're used. this happens independantly and formerly any code is switched over to instructions or static archives. the optimal() function is the cue to the compiler and later the linker as to what's this methodology get admission to ingredient on your code. the rather code this is used to sign the OS and pass it mandatory counsel is named (in many circumstances) "startup" code and is straight away positioned into the logo table via the compiler and/or linker. the tip of this methodology is signified via the last brace, '}', on the tip of the optimal function. The compiler and linker continually use the outlet and shutting braces of any function because of the fact the get admission to and go out of that function. because of the fact the single in substantial() are the point which start up your application, they're the pairing that end it as nicely. that's the reason something which you do outdoors of the optimal() function that may not a international archives assertion, a preprocessor command, a function assertion or function definition will produce an errors or be completely surpassed over via the compiler. for the reason that C++ will assemble a C application this is an errors. you may application something which you wanted in C or C++ without the header documents as long because of the fact here rules are obeyed: a million) each function declared has a valid function definition. 2) The function assertion or definition(for purposes without an convey assertion) looks formerly the optimal() function. 3) Everthing looks in acceptable suited order as above in a single enormous, grotesque source document. Agreed that this makes it so lots greater paintings to application issues and you may could desire to be attentive to an excellent sort of low point stuff to make it paintings, yet that does no longer mean it won't be in a position to be performed.
2016-10-01 22:41:09
·
answer #5
·
answered by Anonymous
·
0⤊
0⤋
Pointers increases the execution speed ,its rite...
it is one of the advantages of pointers,thts y we r going for pointers!!
2007-02-24 15:48:16
·
answer #6
·
answered by Dhilip !! IRRESISTIBLE!!! 2
·
0⤊
0⤋