I'm having a problem with the this pointer inside of a custom class. My code looks as follows.
class Foo(){
public: void bar(); bool baz();
};
bool Foo::baz(){
return true;
}
void Foo::bar(){
bool is_baz = (*this).baz();
}
As I said above, I believe the error I'm getting (LNK2019) is coming from the this. I think it is l...
I'm trying to learn about C pointers but I cannot understand somethings...
The following code:
#include <stdio.h>
void foo(int *x, int *y);
void foo(int *x, int *y) {
printf("x = %p\ny = %p\n", &x, &y);
*x = 5;
*y = 6;
}
int main(void) {
int a, b;
printf("a = %p\nb = %p\n", &a, &b);
foo(&a, &b);
return 0;
...
#include <stdio.h>
#include <stdlib.h>
void foo(int *a, int *b);
void foo(int *a, int *b) {
*a = 5;
*b = 6;
a = b;
}
int main(void) {
int a, b;
foo(&a, &b);
printf("%d, %d", a, b);
return 0;
}
Why a = b (foo) doesn't work? printf outputs "5, 6"
Thank you.
...
How can I have a solid understanding of C pointers?
How should I direct my way of thinking about pointers in C?
...
Hi,
Can you please explain to me what is happening here?
char data[128]; // Create char array of size 128.
long * ptr; // Create a pointer.
ptr = (long *) data; // ??
Mainly, what does the (long *) mean?
Does it mean that the data is of type char, and I am casting the reference to data as a reference to a long?
Thank you.
...
------------ ------------
| TclObjct | | Handler |
------------ ------------
|__________________________________|
|
--------------
...
While reading answers to this question I noticed that answers (this for example) imply that operator delete can be called even when delete statement is executed on a null pointer.
So I wrote a small snippet:
class Test {
public:
void* operator new( size_t ) { /*doesn't matter*/ return 0; }
void operator delete( void* ptr ) {
...
hi
i have come across a line that is given below
char *ch=(char*)3000
i want to know the meaning of this line .....
...
I need a container of pointers. Would you recommend boost::ptr_vector<T> or std::vector<boost::shared_ptr<T> >? (Or something else?)
If that's of interest, my actual data structure is relatively complicated (see here) and currently stores objects, not pointers, but i'd like to change that (using pointer containers), in order to get rid ...
We have a 32-bit app which interfaces with a 64-bit COM control. In order to handle the interface, I created a 64-bit COM object which resides in a local server (exe). This local server object implements the same interface as our COM control, and simply passes-through the calls. Everything is working except for those interface functio...
Hi,
I have a C function in which I have 4 pointers and each of them point to different locations of a large 2D array of floats.
Because the ARM assembly functions can only be passed with 4 parameters (r0 - r3), I'm not able to understand how to pass the pointer to my return value, which will become the 5th parameter to my assembly func...
Hello,
gcc 4.4.4 c89
I am just wondering why I am getting different memory address. When I print the address of animals in main I get the following:
animals [ rabbit ] : [ 0xbfab2e48 ]
animals [ rabbit ] : [ 0xbfab2e48 ]
However, when I print in the function, I get different memory locations. I think they should be the same.
ptr an...
I need to get pointer to my class instance inside this instance. I can't use "Self" directly, I need store pointer for future usage. I tried next code:
type
TTest = class(TObject)
public
class function getClassPointer: Pointer;
function getSelfPointer: Pointer;
end;
class function TTest.getClassPointer: Poin...
I have a function getNum(), which gets a number from file and returns it. When I go back into getNum() I have lost the pointer and it starts at the begging of the file again. I'm wondering How do I get the location of where getc is and then go back to that place. I couldn't find how to do this in the manual or in forums. Thank you.
#inc...
Hi I am using a 3rd party library in my iPhone application that uses C++ one of the methods i need to use returns a pointer to a pointer of a class. like follows.
DLL classAttributes** getAttributes();
I can successfully call the method and return the value into a pointer to a pointer like so;
classAttributes **attributes = cPPClass-...
I have this:
typedef void (*funcptr) (void);
int main(){
funcptr(); //this can compile and run with no error . WHAT DOES IT MEAN? WHY NO ERRORS?
}
...
getLine is a function that gets a line, I'm trying to combine lines together outside the getLine function. When ever I try doing this in a loop it messes up the output. I bet it has to do with the pointers, but I have spend many hours trying to figure it out.
int num;
int matrix[370];
i=1;
j=0;
while(*(point=getLine(infile)) ...
Why can I not do this?
boost::shared_ptr<QueuList> next;
void QueuList::SetNextPtr(QueuList* Next)
{
boost::mutex mtx;
boost::mutex::scoped_lock lock(mtx);
{// scope of lock
//if (next == NULL) // is this needed on a shared_ptr??
next = Next; // Why can I not assign a raw ptr to a shared_ptr????
}
}...
Hello :)
I am interposing the memcpy() function in C because the target application uses it to concatenate strings and I want to find out which strings are being created. The code is:
void * my_memcpy ( void * destination, const void * source, size_t num )
{
void *ret = memcpy(destination, source, num);
// printf ("[MEMCPY] = %...
Hey guys I'm trying to figure how pointers are returned by strcat(), so I tried implementing my own strcat() to see how it works. The following is my code for mystrcat(), which works like the real strcat():
char *mystrcat(char *destination, char *source)
{
char *str = destination;
while (*str != '\0')
{
str++;
}...