w***@remov.yahoo.com
2007-06-04 22:55:08 UTC
This is really a basic question, my only excuse is I am learning C++ and
Borland Builder at the same time.
I have an App that has two forms, in the main form ( Form1) I have declared
a pointer to a struct.
I can use that point fine within the main form, but I can not access it in
the second form.
I know it is a simple error, but digging thru the books I can not seems to
find the solution.
Form1.cpp
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TForm1 *Form1;
data *bb = new data; // data is a structure declared in unit2.h
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
bb->a = 24;
bb->b = 36; // This works Fine,
no problems
Label1->Caption = bb->a;
Label2->Caption = bb->b;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
delete bb;
}
//-------------
Form2.cpp
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Unit3.h"
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TForm3 *Form3;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm3::FormActivate(TObject *Sender)
{
Label1->Caption = Form1->bb->a; // This is my problem line,
Compiler says
//"bb is not a member of TForm1"
}
//
I know I have just done a declartion wrong somewhere, but am not having any
luck figuring it out tonight. Just a pointer in the right direction would be
great.
Thank you in Advance...
Michael
Borland Builder at the same time.
I have an App that has two forms, in the main form ( Form1) I have declared
a pointer to a struct.
I can use that point fine within the main form, but I can not access it in
the second form.
I know it is a simple error, but digging thru the books I can not seems to
find the solution.
Form1.cpp
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TForm1 *Form1;
data *bb = new data; // data is a structure declared in unit2.h
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
bb->a = 24;
bb->b = 36; // This works Fine,
no problems
Label1->Caption = bb->a;
Label2->Caption = bb->b;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
delete bb;
}
//-------------
Form2.cpp
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Unit3.h"
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TForm3 *Form3;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm3::FormActivate(TObject *Sender)
{
Label1->Caption = Form1->bb->a; // This is my problem line,
Compiler says
//"bb is not a member of TForm1"
}
//
I know I have just done a declartion wrong somewhere, but am not having any
luck figuring it out tonight. Just a pointer in the right direction would be
great.
Thank you in Advance...
Michael