Okay, I have a function which reads a xml file and creates controls using new and stores them in public member variables of a class called Window:
std::map<const char*, Button*> Buttons;
std::map<const char*, TextBox*> TextBoxes;
std::map<const char*, CheckBox*> CheckBoxes;
The Button, TextBox and CheckBox classes are homemade wrapper...
What is the right way to typedef a type and the same type's pointer? Here is what I mean. Should I do this:
typedef unsigned int delay;
typedef unsigned int * delayp;
Or should I do this:
typedef unsigned int delay;
typedef delay * delayp;
Or perhaps I should not typedef pointer at all and just use delay * instead of delayp everywh...
Hii ,
I have been trying to write a program... We have a structure which has a rank field and the name field.The pointer to this structure is stored in an array of fixed size. I have implemented it as follows and i have certain problems...
The code i have written is :
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
typedef st...
I need to write code for a callback function (it will be called from within ATL, but that's not really important):
HRESULT callback( void* myObjectVoid )
{
if( myObjectVoid == 0 ) {
return E_POINTER;
}
CMyClass* myObject = static_cast<CMyClass*>( myObjectVoid );
return myObject->CallMethod();
}
here the void* is...
Hi,
static int
write_stream(const void *buffer, size_t size, void *app_key)
{
char *stream = (char *)app_key;
return 0;
}
what am I doing wrong here? Why pointer casting does
not result in a copying of (size_t size) bytes from buffer into the
stream defined by app_key?
Thanks
am calling this function as argument of anot...
I am currently trying to make a call to this function call. Here's the declaration:
const void* WINAPI CertCreateContext(
__in DWORD dwContextType,
__in DWORD dwEncodingType,
__in const BYTE *pbEncoded,
__in DWORD cbEncoded,
__in DWORD dwFlags,
__in_opt PCERT_CREATE_CONTEXT_PARA pCreatePara
);
As ...
Maybe is a silly questiion, but I haven't found a solution to what I want. Basically, I would like to declare a pointer to an array of pointers to function pointers to functions with N parameters that returns an const pointer to an int.
The code below is declaring an array of pointers to the function pointers:
int *const (**fptr[10])...
Hi before someone storm "it's simple or duplicate" i swear i've searched but because it's pretty easy i couldn't find it between much more complex ones , unlucky maybe. Anyway my question is very simple , I have normal array int arr[5] that is passed to function fillarr(int arr[]) all i want is fixing the next code:
int fillarr(int arr[...
How does a variable in C/C++ work?
I mean, a pointer stores an address from a variable and then you have to dereference it to access the object to which it refers, so I think that a variable is a pointer that is dereferenced automatically when used... does that make any sense?
BTW, I didn't find an answer to this on google...
Thank yo...
I have a number of Typed TLists which I am having problems getting to sort
Normally, for an untyped TList, I would have a function such as:
function SortByJob(Item1: Pointer; Item2: Pointer): Integer;
var
p1, p2: JobPointer;
begin
p1 := JobPointer(Item1);
p2 := JobPointer(Item2);
if p1.job > p2.job then
Result := 1
...
Hi
I have read(Inside C++ object model) that address of pointer to data member in C++ is the offset of data member plus 1?
I am trying this on VC++ 2005 but i am not getting exact offset values.
For example:
Class X{
public:
int a;
int b;
int c;
}
void x(){
printf("Offsets of a=%d, b=%d, c=%d",&X::a,&X::b,&X:...
hi, i've a class and there is an array set as private, how do i make the get_array() function i mean how do i return that array knowing that i will have to return a pointer of arr[0] as we know , but isn't this breaking the private rule ? is there other way of returning array ?
I actually thought of having array2 in the main , then edit...
I am looking for a way to transfer the variable addresses back and forth between C++ and Lua. For instance, transferring an object from C++ to Lua and do some processing, then transfer it back to C++.
However, the thing is how can you execute a C++ functions or methods from Lua? Or is a workaround required?
If possible, could you incl...
Should I free the memory allocated for the char array, pointer to which is returned by the char * getenv( char * ) function? And which way - C free() or C+ delete []? If no - why?
I mean:
char * ptr = getenv( "LS_COLORS" );
cout << ptr << endl;
delete [] ptr; //Is this or free() call needed?
Thank you.
...
I am trying to overload the assignment operator to do a deep copy of a polygon object, the program compiles but I am getting an error toward the end that I want to clear up. Below is the relevant code, if you think I need to add more please just post a comment. Assume the proper #include's and that the << operator is overloaded for prope...
I have to access a POS terminal under ms windows xp. I am using python 2.7.
The crucial function in the DLL I load that does the payment accepts two pointer to structures, but it crashes returning 1 (Communication error) but without further messages.
Please note that when the payment function is called, not all the elements of POSData st...
In a program to simulate logic gates I switched from using arrays
node N[1000];
to vectors
vector<node> N;
And my program did work perfectly before using vectors but now it prints wrong results, so I tried debugging and I found out that the bug happens here:
node* Simulator::FindNode(string h)
{
int i;
for(i = 0; i < NNo...
I'm currently self-studying C for mastering an university project. In that project we have several signatures given that we need to implement for solving our task. After several hours of trying to make some progress, I must admit that I'm totally confused about the return types of functions. I will show you some code:
This is a structur...
Couldn't figure out how to word the question accurately, so here's an example:
Given this function prototype:
void Foo(myClass* bar);
I want to prevent this usage:
Foo(new myClass());
and instead require a previously created object:
myClass* bar = NULL;
bar = new myClass();
Foo(bar);
or
myClass bar;
Foo(&bar);
Thanks.
EDI...
How does this code concatenate the data from the string buffer? What is the * 10 doing? I know that by subtracting '0' you are subtracting the ASCII so turn into an integer.
char *buf; // assume that buf is assigned a value such as 01234567891234567
long key_num = 0;
someFunction(&key_num);
...
void someFunction(long *key_num) {
f...