Take this piece of code:
int a;
int *pointer = &a;
int **b = &(&(*pointer));
Would the above set b to the address of pointer or not?
The reason I ask is because *pointer gives the value of a, and the reference of that is the address of a. Is this treated as just the address of a, or is it also treated as pointer.
Does this make sen...
Okay, I am trying to integrate some C code into a C++ project, and have run into a few problems. I will detail the first one here.
I keep running into this error:
error: cannot convert 'char*' to 'char**' in assignment|
here is the offending code (with the breakpoint marked):
char** space_getFactionPlanet( int *nplanets, int *faction...
What is difference between our usual pointers(ones which we normally use), near pointers and far pointers and is there a practical usage for near and far pointers in present day C/C++ systems? Any practical scenario which necessiates use of these specific pointers and not other c,c++ semantics will be very helpful.
...
I have a class called AString. It is pretty basic:
class AString
{
public:
AString(const char *pSetString = NULL);
~AString();
bool operator==(const AString &pSetString);
...
protected:
char *pData;
int iDataSize;
}
Now I want to write code like this:
AString *myString = new AString("foo");
if (myString == ...
Hi,
If I create a class MyClass and it has some private member say MyOtherClass, is it better to make MyOtherClass a pointer or not? What does it mean also to have it as not a pointer in terms of where it is stored in memory? Will the object be created when the class is created?
I noticed that the examples in QT usually declare class ...
I am working on C firmware project. I have a union that is defined as,
typedef union {
unsigned long value;
unsigned char bytes[4];
} LONGVALUE;
I also have a function that has this prototype,
char sendHexToASCII_UART(char *msg, int cnt);
and a variable of type LONGVALUE defined as,
LONGVALUE countAddr;
THE PROBLEM:
I f...
I want to pass a pointer to a function. I want this pointer to point to some place in the middle of an array. Say I have an array like such unsigned char BufferData[5000];, would the following statement be correct syntactically?
writeSECTOR( destAddress, (char *)( BufferData + (int)(i * 512 )) );
// destAddress is of type unsigned long...
Hello, all! I don't know if 'overridden' is the right word here. In my
programming class, I have to create a circular list, such that each node
node contains a pointer pointing to the next node and the final node
points to the first node. In addition, there is a tail node that points to
the last node added (its null before any nodes are ...
How does it work when I only have an object but my function takes a pointer to that type of object.
Someoclass test1;
SomeFunction( Someclass*)
{
//does something
};
...
Hi, I have an array of chars and a pointer to it. I need to add the first 8Bytes (binary value of the 8 Bytes) to the second 8 bytes modulo 2exp(64). How could I do that?
I found a solution. But it is definitely not good to do such things (see the code). Nevertheless it would be nice to have the result in chars array.
void init(const u...
Hi,
What is the difference between these two types of pointers? As far as I can read, QSharedPointer can handle situation well, so what is the need for QSharedDataPointer?
...
I've got a problem- I assign my pointer variable to something in a called function, but when trying to access the updated pointer in the calling functions, it doesnt show as updated, and results in a seg fault. Help!
"Bottommost function":
void compareStrings(char* firstFrag, char* secondFrag, int* longestCommonLength, char* suffix, ch...
I have a program that is highly multi-threaded and it contains an intrusive linked list of objects. I need to pass off the objects in this list to several threads, but only 1 thread will ever own the object at a time, meaning that I don't need this object or the pointer to it be shared.
I wanted to create an intrusive list with a uniqu...
I need to write my own memory allocation functions for the GMP library, since the default functions call abort() and leave no way I can think of to restore program flow after that occurs (I have calls to mpz_init all over the place, and how to handle the failure changes based upon what happened around that call). However, the documentati...
Hi all,
I have a function that takes an int-pointer and exposed it via boost::python. How can I call this function from python?
in C++ with boost::python:
void foo(int* i);
...
def("foo", foo);
in python:
import foo_ext
i = 12
foo_ext.foo(i)
results in
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Boos...
I want to take some fields from packet struct using pointer arithmetic.But what is wrong with the code below ?
In first condition i think if i go 4 byte(2 short field) from beginning of packet i get tLow .But it does not give expected value.Additionally second case i want to get data field by going 12 byte from beginning of packet .What ...
Possible Duplicate:
Determine if Type is a pointer in a template function
I am looking for a method to determine whether a template is a pointer or not at compiling time. Because when T is not a pointer, the program will not compile as you cannot delete a normal type variable.
template <typename T>
void delete(T &aVar)
{
...
typedef struct {
employeeT *employees;
int nEmployees;
} *payrollT;
typedef struct {
string name;
} *employeeT;
I need to do this without accessing it as an array:
employeeT e = payroll.employees[i];
but this gives me an error(expected identifier before '(' token) :
employeeT e = payroll.(*(employee+i));
before struc...
I've been converting a bunch of old C++ code into C++/CLI code, and I think I've coded myself into a corner.
My goal was to take an unmanaged c++ library and a bunch of header files and expose their functionality to a C# solution. From reading on the internet, the standard way to do this is to:
Create two c++ classes: one managed, th...
" Double pointers are also sometimes employed to pass pointers to functions by reference "
can somebody can explain me the above statement, what exactly does point to function by reference means ?
...