Hi,
the question is simple...
is there any difference in using this->yourvariable or yourvariable directly for some reason?
I am not finding any problem with that, but I am using this-> a lot and would like to know if there is any difference before going further.
I saw a comment on a post here and I don't remember which thread, but th...
Dear all,
I have been told by my colleague that this is used like an out parameter in C#, can some precisely explain how? I get the idea, but there is something that is missing.. I know that if we pass the pointer itself p to foo (*p), and the function body does p = new int(), we might have a dangling modifier! what I don't get is how f...
char *str = NULL;
str = Operation(argv[1]);
cout << Cal(str);
Operation function return a pointer, but I really don't know why str in Cal is null.
in line 2, it still has content. What am I missing?
...
Maybe my memory has gone completely wacko, but I think I remember that declaring pointers without initializing them made them point to nil. But recently this doesn't seem to be the case. Has it always been this way? Or has it something to do with the compiler settings?
...
I tried to compile the following code, but the compiler wouldn't doing because " * is illegal for a struct" is that true?
struct String {
int length;
int capacity;
unsigned check;
char ptr[0];
} String;
void main(){
char *s;
String *new_string = malloc(sizeof(String) + 10 + 1);
}
...
In the following lines of code, I need to adjust the pointer pm by an offset in bytes in one of its fields. Is there an better/easier way to do this, than incessantly casting back and forth from char * and PartitionMap * such that the pointer arithmetic still works out?
PartitionMap *pm(reinterpret_cast<PartitionMap *>(partitionMaps));
...
Let's say we have an array of PRINTER_INFO_2 like this:
PRINTER_INFO_2* printers = (PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2) * 64); // room for 64 items
Then we call EnumPrinters() to get a list of locally installed printers:
EnumPrinters(
PRINTER_ENUM_LOCAL,
NULL,
2,
(LPBYTE)printers,
...);
Here's the stru...
In Visual Studio 2008, is there a way of finding all the variables that point to the same object as another variable?
So in the example below I would want to find out that ref1 and ref2 both point to the same object as original.
var original = new List<string>() { "Some Data" };
var ref1 = original;
var ref2 = ref1;
Essentially I wan...
Hey all, here's the deal...
I've got a UIImage that is being loaded in the background via an NSURLConnection within a subclassed UIImageView. Until the data finishes downloading, a placeholder image is shown. The UIImage needs to be used by another, separate UIImageView, as well.
The problem I'm having is that if I set the second UIIm...
void main(){
int i,k;
char* p;
int j;
printf("address of i is %d \naddress of k is %d \naddress of p is %p\naddress of j is %d", &i,&k,&p,&j);
}
when I tried the above code, the address of j is 4 units below k. But the address of p is no where near. Since a pointer is an integer variable that could store 4 bytes of dat...
Hi,
i want to build a pointer to a Qt Slot:
union {
void (*set_slot)(unsigned long value);
void (*refresh_slot)(void);
} the_slot;
The slot definition is:
void set_pwm(unsigned long new_pwm);
I try to do something like this:
the_slot.set_slot = set_pwm;
But the compiler says that the signature does not match:
error:...
template <class Enum>
class EnumIterator {
public:
const Enum* operator-> () const {
return &(Enum::OfInt(i)); // warning: taking address of temporary
}
const Enum operator* () const {
return Enum::OfInt(i); // There is no problem with this one!
}
private:
int i;
};
I get this warning above. Currently I'm us...
Afternoon all,
a little help if you please. In order to circumvent the 2Gb object limit in .NET I have made a class that allocates memory on the heap and this allows me to create arrays up to the limit of my free RAM. However, for ease of development (as it was a proof of concept) it was hard coded for longs. Now that it works I've been...
At the moment, i'm trying to create a Java-application which uses CUDA-functionality. The connection between CUDA and Java works fine, but i've got another problem and wanted to ask, if my thoughts about it are correct.
When i call a native function from Java, i pass some data to it, the functions calculates something and returns a resu...
I'm trying to teach myself C++, and one of the traditional "new language" exercises I've always used is to implement some data structure, like a binary tree or a linked list. In Java, this was relatively simple: I could define some class Node that maintained an instance variable Object data, so that someone could store any kind of object...
in C is:
*(array) equivalent to array[0]?
Therefore is
*(array+2) equivalent to array[2]?
...
Please tell me what will the call to given function return and how? The code:
typedef struct {
int size;
ptrdiff_t index;
void (*inlet) ();
int argsize;
ptrdiff_t argindex;
} CilkProcInfo;
/*
* Returns a pointer to the slow version for a procedure
* whose signature is p.
*/
/* the function definition is - */
st...
If we have this code:
int foo=100;
int& reference = foo;
int* pointer = &reference;
There's no actual binary difference in the reference's data and the pointer's data. (they both contain the location in memory of foo)
part 2
So where do all the other differences between pointers and references (discussed here) come in? Does the com...
In "The C++ Programming Language", Bjarne writes that the null pointer is not the same as the integer zero, but instead 0 can be used as an pointer initializer for a null pointer. Does this mean that:
void * voidPointer = 0;
int zero = 0;
int castPointer = reinterpret_cast<int>(voidPointer);
assert(zero == castPointer) // this isn't nec...
I am having a lil hard time with map and the valuetype allocation.
consider this simple class:
class Column {
private:
char *m_Name;
public:
// Overrides
const char *Name(){
return this->m_Name;
}
// Ctors
Column(const char *NewName){
this->m_Name = new char[strlen(NewName) + 1];
strcpy(this->m_N...