473,396 Members | 1,998 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,396 software developers and data experts.

How can i replace a pointer in runtime?

Me
Hey,

First, what i have is a form and a few panels. my code:

if(Partytent->Panel5x5a->Left+Partytent->Panel5x5a->Width >=
Partytent->Panel5x5b->Left-2 && Partytent->Panel5x5a->Top >=
Partytent->Panel5x5b->Top-5 && Partytent->Panel5x5a
->Top+Partytent->Panel5x5a->Height <=
Partytent->Panel5x5b->Top+Partytent->Panel5x5b
->Height+5 && Partytent->Panel5x5a->Left+Partytent->Panel5x5a->Width <=
Partytent
->Panel5x5b->Left+1){
left=1;
}
else
left=0;

Allright, this is a little difficult, so in steps:

The first pointer in the if-statement is:

Partytent->Panel5x5a->Left

What i want is a function where i can give "5x5" with, "a", so
something like this:

void __fastcall TPartytent::checkAfstandTenten(TObject *Sender, String
TypeEerste, String TypeTweede) {

String tmp;
tmp="Partytent->Panel" + TypeEerste + een + "->Left";

and then in the if-statement: if(tmp==100){} for example.

So anyone think this is possible? Or how to do this anyway? The pointer
still has to point to the panel.

I want to change the pointer by call of this function.

Jul 10 '06 #1
1 1220
* Me:
Hey,
Hey hey.

First, what i have is a form and a few panels.
That's outside the scope if this newsgroup: here it's all & only about C++.

my code:

if(Partytent->Panel5x5a->Left+Partytent->Panel5x5a->Width >=
Partytent->Panel5x5b->Left-2 && Partytent->Panel5x5a->Top >=
Partytent->Panel5x5b->Top-5 && Partytent->Panel5x5a
->Top+Partytent->Panel5x5a->Height <=
Partytent->Panel5x5b->Top+Partytent->Panel5x5b
->Height+5 && Partytent->Panel5x5a->Left+Partytent->Panel5x5a->Width <=
Partytent
->Panel5x5b->Left+1){
left=1;
}
else
left=0;

Allright, this is a little difficult, so in steps:

The first pointer in the if-statement is:

Partytent->Panel5x5a->Left
The answer to complexity is abstraction, in essence, /name/ those
sumbitches that appears in your code, like

Panel const& a = *Partytent->Panel5x5a;
Panel const& b = *Partytent->Panel5x5b;

bool const isLeft =
a.Left + a.Width >= b.Left - 2 &&
a.Top >= b.Top - 5 &&
a.Top + a.Height <= b.Top + b.Height + 5 &&
a.Left + a.Width <= b.Left + 1;

What i want is a function where i can give "5x5" with, "a", so
something like this:

void __fastcall TPartytent::checkAfstandTenten(TObject *Sender, String
TypeEerste, String TypeTweede) {

String tmp;
tmp="Partytent->Panel" + TypeEerste + een + "->Left";
No, you can't (in general) generate code on the fly in C++. What you
can do is use abstraction, /name/ those things. E.g. define a type
PanelPair, where one instance is named 5x5, containing panels a and b.

and then in the if-statement: if(tmp==100){} for example.
Huh.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 10 '06 #2

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

Similar topics

1
by: Dale | last post by:
I'm trying to use the DdeInitialize() function from an external DLL in my C# code. The first parameter is described as LPDWORD, which seems to be a pointer to a DWORD. I believe that the DWORD is...
5
by: DamonChong | last post by:
Hi, I am still struggling to master C++ and is trying to understand how to achieve passing arguments using pointers. I got some questions that I like to post to the experts here, hope you can...
19
by: Paul | last post by:
hi, there, for example, char *mystr="##this is##a examp#le"; I want to replace all the "##" in mystr with "****". How can I do this? I checked all the string functions in C, but did not...
48
by: yezi | last post by:
Hi, all: I want to record some memory pointer returned from malloc, is possible the code like below? int memo_index; int i,j; char *tmp; for (i=0;i<10;i++){
4
by: Lauren Wilson | last post by:
Hi folks, We have a need to replace sub strings in certain message text. We use the Office Assistant to display help and often use the imbedded formatting commands. Those of you who have used...
13
by: al.cpwn | last post by:
I get that these two are different int* get() { static int m; return &m; } int& get() {
49
by: elmar | last post by:
Hi Clers, If I look at my ~200000 lines of C code programmed over the past 15 years, there is one annoying thing in this smart language, which somehow reduces the 'beauty' of the source code...
23
by: main() | last post by:
Hi all, I have three newbie questions : 1) According to my understanding, main function can be defined in any of the following two ways, int main(void) int main(int argc,char *argv) How...
18
by: Umesh | last post by:
Do you have any answer to it? thx.
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.