A pointer is a data type that "points to" another value stored in memory using its address. Pointers have a variety of performance benefits in repetitive operations. For example, copying a pointer is "cheaper" than copying the value that it points to because only the address must be copied. Pointers ...
4
votes
6answers
82 views
How to check when a pointer is deleted?
When I debugging someone else's code, how could I found when a pointer is deleted?
1
vote
0answers
38 views
Writing to specific memory location in B
In C, you can write something like unsigned char *ptr = (unsigned char *)0x8000;, and then write to 0x8000 with *ptr = 0x43;.
My question is: how can this be done in B?
1
vote
3answers
44 views
cast to pointer from integer
i'm studying casting in c++ and the code after is magic to me.
#include <iostream>
using namespace std;
class Base {
public:
virtual void f() { }
};
#define SOME_VALUE 8
int main() {
cout ...
0
votes
4answers
30 views
Store pointer pointing to object contained in map
Im wondering whether this snippet of code will actually store a pointer pointing to object which is managed by a map:
std::map<std::string,MapType> map;
MapType* typePointer;
typePointer = ...
-2
votes
2answers
38 views
C behavior with pointer addition
Given:
int a[N];
int *p;
why does a-p work yet a+p does not with error: "invalid operands to binary +".
0
votes
1answer
33 views
C++ passing a struct and passing a pointer interchangeable?
If the function is:
void foo(struct* bar)
{
}
And
struct foobar;
Is a single instance of struct, will the call
foo(foobar);
Be treated as if it were a pointer to a one member array? Will the ...
3
votes
1answer
70 views
C++ Class/Vector pointer problems
I'm trying to use a vector of pointers of a class. When trying to access any of the members of the Agent class, I either get a bad pointer or null data. The code is the following.
class Grue : public ...
-3
votes
2answers
65 views
Advanced usage of pointers in C [closed]
My question is simple, where can i get some examples and explanation of using pointers of pointers, tables of pointers to function, using pointers with functions, and such ?
What ...
6
votes
3answers
88 views
C++ * vs [] as a function parameter
What is the difference between:
void foo(item* list)
{
cout << list[xxx].string;
}
and
void this(item list[])
{
cout << list[xxx].string;
}
Assuming item is:
struct item
{
...
1
vote
2answers
50 views
Covariant return type with non-pointer/reference return type
I'm trying to implement a .NET framework like collection class in C++(11). My problem is an invalid covariant type. I have these classes:
template<typename T>
class IEnumerator
{
public:
...
-3
votes
2answers
120 views
What is native pointer and how to use it?
In c++,what is native pointers and what is the difference between native pointers and other pointers, in what case we need to use native pointers?
Can anyone help me on this?
0
votes
4answers
79 views
Do the advantages of using references over using pointers justify occasional “null-references”?
I'm currently designing a class hierarchy that looks roughly like this:
struct Protocol
{
// Pass lower-layer protocol as a reference.
Protocol(Protocol & inLLProtocol) :
...
-2
votes
2answers
71 views
Manipulating a struct in C using functions
I'm trying to manipulate an dynamically allocated matrix declared as global pointer using functions, for sake of simplicity I'm not gonna paste here the code but I'll provide an equivalent, and ...
1
vote
2answers
66 views
Local pointer to a global function
I want to use a local pointer to point to a global string. The pointer is a local pointer and the string is global. When I run this code passing the local pointer to the function "myfun" the pointer ...
-2
votes
3answers
76 views
strange error in passing pointers (*&) in constructor
i'm not a c++ guru at all, and i've tried to replicate this error in variuos little trials. the fact is that when i do a little program with 2 o 3 classes with what i wanto to do, there is no error. ...