I'm currently trying to manipulate TShape objects over multiple classes, I had a problem with #includes and now that is sorted, the only thing i'm trying to do is create shapes on one form from another class, by creating the function and then calling it in my main class, here's my code:

void __fastcall TStackBuild::StackA(void)
{
		int a = 1;
		while (a > 0)
			{
			 TShape* tokena;
			 tokena = new TShape(this);
			 tokena->Parent = frmNim->pnlA;
			 tokena->Shape = stRectangle;
			 tokena->Brush->Color = clWhite;
			 tokena->Width = 20;
			 tokena->Height = 20;
			 tokena->Top = 15;
			 tokena->Left = -10 + (22 * frmNim->pnlA->ControlCount);

			 a--;
			}
}

and then for calling it in the main form i'm using the following:

TStackBuild* StackA();

This is nested within a button's click event.

All compiles and runs well but when the button is clicked, nothing happens, not sure where I have gone wrong. Can anyone help?

void __fastcall TStackBuild::StackA(void)

...is a member function of TStackBuild.

The statement...

TStackBuild* StackA();

...is a declaration of a variable of type "TStackBuild*" with name "StackA" and a default constructor (wich is empty for pointers).

It seems, that the compiler is compiling the right thing: Nothings has to happen by this statement.

On the other side: What you probably intended to do is:

TStackBuild some_frame_window;
some_frame_window.StackA();

Right?

not sure i'm understanding you. Id just like the method to run when I clicked the button, in VB it just used to be

call method()

I guess without schooling C++ can be confusing.

it just used to be

call method()

That's the same in C++ as in any language. Just call the function! Do not declare variables!
If you need a little more help with that code, post some line around that expressions and we will see...

I should maybe have stated I'm using C++ Builder, doesn't recognise the 'call' function, states it is an undefined symbol. The two units are linked via #includes yet referring to

StackA();

or

TStackBuild->StackA/TStackBuild::StackA();

does nothing!

Well, possibly you need to acquire knowledge about defining and using structures with functions? It doesn't look like a learning example. I recommend to first learn the basics and only after that begin to work on complex use cases.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.