I have a class named SuperclassA, and an class named ClassA. ClassA inherits from SuperclassA.
SuperclassA has got an property called something, so a very generic not-much-saying name. In ClassA, I want to have an property which maps to that something of SuperclassA.
How could I do that? I want to make absolutely sure that any access t...
Is deleting a pointer same as freeing a pointer (that deallocates the memory)?
...
I'm having a weird problem with memset, that was something to do with a class I'm creating before it and a file I'm opening in the constructor. The class I'm working with normally reads in an array and transforms it into another array, but that's not important. The class I'm working with is:
#include <vector>
#include <algorithm>
using ...
I have an double array
alist[1][1]=-1
alist2=[]
for x in xrange(10):
alist2.append(alist[x])
alist2[1][1]=15
print alist[1][1]
and I get 15. Clearly I'm passing a pointer rather than an actual variable... Is there an easy way to make a seperate double array (no shared pointers) without having to do a double for loop?
Thanks,
Da...
In Objective-C, I've seen, for example:
UIPickerView *tweetPicker
and
UIPickerView* tweetPicker
What does the asterisk mean (I know, the first part is a dupe...) and why does it go on different parts of the deceleration in different contexts?
...
I'm working on a texture management and animation solution for a small side project of mine. Although the project uses Allegro for rendering and input, my question mostly revolves around C and memory management. I wanted to post it here to get thoughts and insight into the approach, as I'm terrible when it comes to pointers.
Essentiall...
I was wondering about the last constructor for std::string mentioned here. It says:
template<class InputIterator> string (InputIterator begin, InputIterator end);
If InputIterator is an integral type, behaves as the sixth constructor version (the one right above this) by typecasting begin and end to call it:
string(static_cast<size_t...
Hi everyone, even though it is possible to write generic code in C using void pointer(generic pointer), I find that it is quite difficult to debug the code since void pointer can take any pointer type without warning from compiler.
(e.g function foo() take void pointer which is supposed to be pointer to struct, but compiler won't compla...
I am getting segmentation fault in this code but i cant figure out why. I know a segmentation fault happens when a pointer is NULL, or when it points to a random memory address.
q = p;
while(q -> link != NULL){
q = q -> link;
}
t = new data;
t -> city = cityName;
t -> latitude = lat;...
How in C++ get array length with pointers only ? I know that tab name is pointer to first element, but what next ?
...
struct struct0 {
int a;
};
struct struct1 {
struct struct0 structure0;
int b;
} rho;
&rho->structure0; /* Reference 1 */
(struct struct0 *)rho; /* Reference 2 */
(struct struct0)rho; /* Reference 3 */
From reference 1, does the compiler take the address of rho, and then access structure0, or vice-versa?
What does the line at ...
Hi
I am new to pointers in C. I know the basic concepts. In the below code, why is it printing the "ink" as its output?
#include<stdio.h>
main()
{
static char *s[]={"black","white","pink","violet"};
char **ptr[]={s+3,s+2,s+1,s},***p;
p=ptr;
++p;
printf("%s",**p+1);
}
Thanks
...
Hello, I have a class A containing two pointers to objects of another class B. I want to initialize one pointer or the other depending on which one is passed to init(), which also takes other parameters. My situation is thus the following:
class A {
public:
A();
init(int parameter, int otherParameter, B* toBeInitialized);
prot...
I am having problems here if I want to check if eerste points to nothing I get
Blockquote
Unhandled exception at 0x003921c6 in
Bank.exe: 0xC0000005: Access violation
reading location 0xccccccd0.
and I am kinda wondering why he justs skips the if statement or doens't stop when the object eerste points to nothing
Bank::Ban...
Is there any difference in performance - or otherwise - between:
ptr->a();
and
(*ptr).a();
?
...
What is the difference between
char *foo
and
(char *) foo
in Objective-C?
Here is an example for both scenarios:
1. @interface Worker: NSObject { char *foo; }
2. - initWithName:(char *)foo
...
I have BYTE pointer. For example the length of this BYTE array is 10.
How can I read 4 bytes from 3 position BYTE array?
Now I doing it so
BYTE *source = "1234567890\0";
BYTE* tmp = new BYTE[4+1]();
for(int i=0; i<4; i++)
{
tmp[i] = source[i+3];
}
...
I have some legacy code I want to port to C#. I cannot modify the C++ code, I just have to make do with what I'm given.
So, the situation. I'm using SwIG, and I came across this function:
void MarshalMe(int iNum, FooClass** ioFooClassArray);
If I ran SWIG over this, it wouldn't know what to do with the array, so it will create a SWIG...
Is there a simple way to convert a System.Drawing.Pen into its unmanaged counterpart? Like, if you had a Pen like this:
Pen p = new Pen(Color.Blue, 1f);
IntPtr ptr = p.ToPtr();
I know this code doesn't work, but is there a way to do it similarly?
...
I can't seem to figure out what's wrong with my function.... I need to ask the user for a price and then return it as a double pointer, but I get tons and tons of errors:
double* getPrice()
{
double* price;
cout << "Enter Price of CD: " << endl;
cin >> &price;
return price;
}
...