Vector iterator
I have class CBase { ....... }; class CDerived : public CBase { ...... }; vector<CBase*> mpBase; vector<CDerived*>::iterator InfoIt; InfoIt=mpBase.begin(); VC++ 2008 generates error C2679. What's wrong? ...
I have class CBase { ....... }; class CDerived : public CBase { ...... }; vector<CBase*> mpBase; vector<CDerived*>::iterator InfoIt; InfoIt=mpBase.begin(); VC++ 2008 generates error C2679. What's wrong? ...
Total noob to anything lower-level than Java, diving into iPhone audio, and realing from all of the casting/pointers/raw memory access. I'm working with some example code wich reads a WAV file from disc and returns stereo samples as single UInt32 values. If I understand correctly, this is just a convenient way to return the 32 bits of m...
I am using the KVO validations in my cocoa app. I have a method - (BOOL)validateName:(id *)ioValue error:(NSError **)outError My controls can now have their bindings validate. How do I invoke that method with a id * NOT id To use the value that is passed in (a pointer to a string pointer) I call this: NSString * newName = (NSString ...
I'm trying to save the address of a dynamic array index. The last line of this function is what gives the pointer error. static struct sstor *dlist struct node *ins_llist(char *data, struct llist *l) { struct node *p, *q; q = malloc((size_t)sizeof(struct node)); if(q == NULL) return(NULL); if(ins_list(data, &dli...
I create a 2D array in C as follows: int **arr; arr = malloc(rows * sizeof(int *)); for (i = 0; i < rows; i++) arr[i] = malloc(cols * sizeof(int)); Now, I call: func(arr) In the function func, how do I calculate the row and column dimensions? ...
I get that asterix is for pointers, and I understand about pointers now. But I'm still not sure why when declaring a variable in a header I need to use an asterix, for example: UINavigationController * navController; why isn't that: UINavigationController navController; Thanks ...
I know this is probably a stupid question, but I need to be sure; I came accross some legacy code that contains a function like this: LPCTSTR returnString() { char buffer[50000]; LPCTSTR t; /*Some code here that copies some string into buffer*/ t = buffer; return t; } Now, I strongly suspect that this is wrong. ...
When malloc is called, the size is stored adjacent to the allocated block so that free will know how much to free etc ( http://c-faq.com/malloc/freesize.html ). My question is, Say we have dynamically allocated memory and later in the code we increment the pointer pointer++ And then later, if i call a free(pointer) what memor...
What languages other than C and C++ have explicit reference and pointer type qualifiers? People seem to be easily confused by the right-to-left reading order of types, where char*& is "a reference to a pointer to a character", or a "character-pointer reference"; do any languages with explicit references make use of a left-to-right readin...
I have a function that takes a const D3DVECTOR3 *pos, but I have no reason to declare this beforehand. The most logical solution to me was using new: Function( //other parameters, new D3DXVECTOR3(x, y, 0)); but I don't know how I would go about deleting it, beign intitialized in a function. My next thought was to use the & o...
Could somebody tell me the difference between: int *p; p=(int*)malloc(10*sizeof(int)); free(p); or int *p; p=(int*)malloc(10*sizeof(int)); p=NULL; ...
Hi all, how can I set the mouse cursor position in an X window using a C program under Linux? thanks :) (like setcursorpos() in WIN) EDIT: I've tried this code, but doesn't work: #include <curses.h> main(){ move(100, 100); refresh(); } ...
class Base { public: int base_int; }; class Derived : public Base { public: int derived_int }; Base* basepointer = new Derived(); basepointer-> //Access derived_int here, is it possible? If so, then how? ...
In an excel cell, I've placed a simple formula =C4 The cell typically displays the value of cell C4, but instead I want to see the linked cell ID instead, which in this case is "C4". Is there a formula to show me this? like: =SHOWCELL(C4) The reason I need this instead of simply typing the value of "C4" into the cell, is so Excel ...
Hi guys. I read about function pointers in C. And everyone said that will make my program run slow. Is it true? I made a program to check it. And I got the same results on both cases. (measure the time.) So, is it bad to use function pointer? Thanks in advance. To response for some guys. I said 'run slow' for the time that I have comp...
I'm having a little play with google's Go language, and I've run into something which is fairly basic in C but doesn't seem to be covered in the documentation I've seen so far When I pass a pointer to an array to a function, I presumed we'd have some way to access it as follows: func conv(x []int, xlen int, h []int, hlen int, y *[]int)...
Hey all. I'm doing a linked list exercise that involves dynamic memory allocation, pointers, classes, and exceptions. Would someone be willing to critique it and tell me what I did wrong and what I should have done better both with regards to style and to those subjects I listed above? /* Linked List exercise */ #include <iostream>...
hi, do you know if are there pointers in haskell? -If yes, how do you use them? Are there any problems with them? And why aren't they popular? -If no, is there any reason for it? Please help us!! :) Thank you so much!! ...
I'm currently working on a C# wrapper to work with Dallmeier Common API light. See previous posting: http://stackoverflow.com/questions/2430089/c-wrapper-and-callbacks I've got pretty much everything 'wrapped' but I'm stuck on wrapping a callback which contains an array of three pointers & an array integers: dlm_setYUVDataCllback in...
Hi, i asked some time ago on an account i cant remember how to manipulate basic pointers and someone gave me a really good demo for example char *ptr = "hello" (hello = a char array) so now *ptr is pointing at h ptr++ = moves the ptr to point at the next element, to get its value i do *ptr and that gives me e ok so far i hope :D ...