By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,897 Members | 1,969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,897 IT Pros & Developers. It's quick & easy.

How can i replace a pointer in runtime?

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
* 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 discussion thread is closed

Replies have been disabled for this discussion.