Assume I have a such struct:
(define-struct node (value next))
;and making 2 nodes, parent pointing to child as next.
(define child (make-node 2 null))
(define parent (make-node 1 child))
Under PLT Scheme, while having child in my hand (and not knowing that parent is the pointer), is it possible to find the pointing node sctuct with...
Hello. The title is self-explanatory. How can I build a new list X from another list Y (same structure), but the resulting list pointing somewhere else in memory area, practically, another object? I tried with make-list :initial-element Y or appending to an empty list, but I still get the same object. Thanks!
...
This is a method that gets a element from a Sparse Matrix in java. I keep getting a java.lang.NullPointerException error. I have looked over the code and can't find the error.
public int getElement(int row,int col){
int result = 0;
MatrixEntry matrixentry = null;
if ((row >= 0) && (row < getNumRows()) &&
(col >= 0) ...
I'm a tad confused.
I am just getting started with OpenCV and its image data is pointed to by a char pointer. I can't quite work out how that works considering the actual data itself could be any number of data types, e.g. uint, float, double. As far as I knew, a pointer had to be of the same type as the pointer it represents.
It's p...
I was wondering if it is safe to do this...
delete p_pointer;
p_pointer = p_otherPointer;
Rather than...
delete p_pointer;
p_pointer = 0;
p_pointer = p_otherPointer;
I would assume so since there aren't any new memory allocations between the deletion and assignment, but I just want to make sure.
...
I had a quiz at school and there was this question that I wasn't sure if I answered correctly. I could not find the answer in the book so I just wanted to ask you.
Point* array[10];
How many instances of class Point are created when the above code is called?
I answered none because it only creates space for 10 instances, but doesn't ...
When creating an object instance as such in C#
Myclass mc = new Myclass();
This mc is now a reference to a Myclass object created in memory. It's like a 'pointer' to that memory.
Is it the same or comparable to doing this in (Managed or Unmanaged) C++:
MyCppClass *mcCppClass = new MyCppClass();
Because this actually creates a po...
I have the following code:
int takeEven(int *nums, int numelements, int *newlist) {
newlist = malloc(numelements * sizeof *newlist);
int i, found = 0;
for(i = 0; i < numelements; ++i, nums++) {
if (!(*nums % 2)) {
*(newlist++) = *nums;
found++;
}
}
newlist -= found;
printf(...
I know more C++ than C. Does C use -> for pointers, or is that only used in C++?
...
can any body tell the difference between far pointer and near pointer in C?
...
I know Java doesn't have pointers, but I heard that Java programs can be created with pointers and that this can be done by the few who are experts in java. Is it true?
...
Hi all,
I'm new to boost shared arrays.
There is existing code that declares two arrays:
boost::shared_array<unsigned char> src;
boost::shared_array<unsigned char> dest;
All I want to do is swap what each array is pointing to (src becomes dest, and dest becomes src). As I understand it, the shared_array.get() method returns a poin...
I understand I can use pointers for functions.
Can someone explain why one would use them, and how? Short example code would be very helpful to me.
...
I'm trying to write some reasonably generic networking code. I have several kinds of packets, each represented by a different struct. The function where all my sending occurs looks like:
- (void)sendUpdatePacket:(MyPacketType)packet{
for(NSNetService *service in _services)
for(NSData *address in [service addresses])
...
I need help with pointers and memory management.
I need to store different objects, all derived from the same base class, and have been using an array to do this but it is causing a segmentation fault when the array is populated with different objects.
My program works fine when the array is full of objects of the same derived type. ...
In C++, is it possible to define a sort order for pointers to member functions? It seems that the operator< is undefined. Also, it's illegal to cast to void*.
class A
{
public:
void Test1(){}
void Test2(){}
};
int main()
{
void (A::* const one)() = &A::Test1;
void (A::* const two)() = &A::Test2;
boo...
I am trying to build an array that contains arrays of dictionary objects in Xcode. I can create a working array that has one or more dictionaries in it and then use the addObject: method to add this array as an object in my main array. I cycle around this several times, rebuilding the working array and adding objects to the main array....
I'm trying to make a pointer point to a 2D array of pointers. what is the syntax and how would i access elements.
...
I know this is a dumb question, but its really bugging me.
Take the following:
public <TParseable> LinkedList<TParseable> readAllParseable(
Parseable<TParseable> parseable, boolean close) throws IOException
{
LinkedList<TParseable> list = new LinkedList<TParseable>();
byte[] delim = parseable.getDelimiterValue();
...
The following piece of code is causing an exception on a windows vista x64 and i can't figure why.
size_t pBaseAddr;
char *lpszFuncName;
IMAGE_EXPORT_DIRECTORY *pExportDir;
const char **lpszNames;
unsigned int dwIndex;
lpszNames = ((const char **)(pBaseAddr + pExportDir->AddressOfNames));
if(lpszNames == NULL)
return NULL;
for(dwI...