473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Problem with my automatic pointer implementation

Hi,

I assume, to be right here :-)

My automatic pointer implementation is packaged into a macro, that could
be placed into a class definition.

I have the following code (snippets) that brought me to a problem:

UAP(lb_I_Database, database, __FILE__, __LINE__)
UAP(lb_I_Query, sampleQuery, __FILE__, __LINE__)
long l; // This buffer gets overwritten.
char buf[100]; // This not.

wxWindow* firstButton;
wxWindow* prevButton;
wxWindow* nextButton;
wxWindow* lastButton;

If I do not include this long l or the char buffer, I get overwritten
my real in use window member firstButton.

The code line that invokes this overwrite is as follows:

sampleQuery = database->getQuery(0);
Thanks for any help

Lothar
I think these code may be of relevance of the macro:

#define UAP(interface, Unknown_Reference, file, line) \
class UAP##Unknown_Reference { \
public: \
UAP##Unknown_Reference() { \
_autoPtr = NULL; \
_line = -1; \
_file = NULL; \
allowDelete = 1; \
} \
UAP##Unknown_Reference(const UAP##Unknown_Reference& _ref) { \
_file = NULL; \
if (_ref._file) { \
_file = new char [strlen(_ref._file) + 1]; \
_file = strcpy(_file, _ref._file); \
} \
_line = _ref._line; \
} \
void operator=(const UAP##Unknown_Reference& _ref) { \
if (_file != NULL) { \
delete [] _file; \
if (_ref._file) { \
_file = new char [strlen(_ref._file) + 1]; \
_file = strcpy(_file, _ref._file); \
} \
} \
_line = _ref._line; \
} \
virtual ~UAP##Unknown_Reference() { \
} \
} \
UAP##Unknown_Reference& LB_STDCALL operator = (interface* autoPtr) { \
_autoPtr = autoPtr; \
return *this; \
} \
protected: \
interface* _autoPtr; \
int _line; \
char* _file; \
int allowDelete; \
}; \
\
interface* _UAP##Unknown_Reference; \
UAP##Unknown_Reference Unknown_Reference;
Jul 22 '05 #1
0 917

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: August1 | last post by:
This is a short program that I have written from a text that demonstrates a class object variable created on the stack memory and another class object variable created on the heap memory. By way...
102
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler...
46
by: Albert | last post by:
Why doesn't: #include <stdio.h> void reverse(char, int); main() { char s;
19
by: Chocawok | last post by:
Some of the classes in my app are graphical. To encapsulate the graphical side of things I had created a class called "sprite" which holds a bit map and knows how to draw itself etc. The...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
11
by: toton | last post by:
Hi, I have little confusion about static memory allocation & dynamic allocation for a cluss member. I have class like class Bar{ public: explicit Bar(){ cout<<"bar default"<<endl; }
27
by: onkar | last post by:
#include<stdio.h> int main(void){ char a="abcde"; char *p=a; p++; p++; p='z'; printf("%s\n",p); return 0; }
1
by: ilieyah | last post by:
Hi! Sorry for the silly title, but I just couldn't come up with anything sensible. I have some test code here to demonstrate an issue I'm having. What I'm trying to do is implement a reference...
25
by: biplab | last post by:
Hi all, I am using TC 3.0..there if I declare a integer array with dimension 162*219...an error msg saying that too long array is shown....what should I do to recover from this problem???
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.