i need help :(:(.

i need help :(:(.

Post by dentar » Sat, 05 Feb 2005 01:52:22

well,i use visual c++.NET 2003.i am organizing a windows form
application.i attached a form shape to tell my problem( please coppy
this url and have a look :
http://www.yqcomputer.com/ ).according to
that form,say if u select radiobutton1,it will make cruise
calculations whereas if u select radio button 2,it will make descend
calculations. but at the end it will give a profile output.so i neeed
to use one output of a calculation as an input to the others.the
experienced users now may imagine the problem .inside the code:

private: System::Void button1_Click(System::Object * sender,
System::EventArgs * e)

//altitude variable that must be updated by the following cases.

double & altitude;

if (radioButton1->Checked==true)
// CLIMB calculations
// finds altitude here and must update the altitude value!!!!

if (radioButton2->Checked==true)
// DESCEND calculation
// finds altitude here and must update the altitude value!!!!


but the problem is :
d:\c++\samples\lbox\list\Form1.h(311): error C2530: 'altitude' :
references must be initialized

please the experienced users,help me.HOW CAN I INITIALIZE THAT
REFERENCE "altitude"? i dont find it,if u know please tell me.

or u can also help me in another way;
imagine the same code but i define altitude just before the button
click ,like;
double& altitude;

private: System::Void button1_Click(System::Object * sender,
System::EventArgs * e)
and in this case it has an error as:
d:\c++\samples\lbox\list\Form1.h(25): error C2758:
'list::Form1::altitude' : must be initialized in constructor
base/member initializer list

Posted at: http://www.yqcomputer.com/

Posted Via Usenet.com Premium Usenet Newsgroup Services

i need help :(:(.

Post by Larry Bras » Sat, 05 Feb 2005 02:35:41


[Much irrelevant matter excised.]
[and more]

If you need help, you can help the helpers by
choosing a sensible subject line. You may as
well use 'something' or 'post' as what you picked.

As for your reference, it is supposed to reference
an object of the declared type. So, you could
double someActualObjectsName;
double & referringToAnObject = someActualObjectsName;
I cannot say what actual object your reference should
reference. Since you decided to use a reference, you
should know what you intended it to refer to. If not,
you should not be using a reference at all.

--Larry Brasfield
Above views may belong only to me.


i need help :(:(.

Post by Antti Kesk » Sat, 05 Feb 2005 02:37:23

Hi !

It seems that you have several syntax errors in your code. This is a result
of not understanding what you code or in other terms, lack of knowledge.

This is caused by a clear coding error. You have a "double&" variable, which
is a reference to a double-type. References MUST be initialized (e.g. they
must refer to variables) at all times. There can be no 'empty' references.

Well, this is dependant on where you want the it to refer to ? Do you have a
variable somewhere in your code, which holds the altitude level ? A double
value, yes ? Perhaps as a member of the form class ? Where do you get this
'altitude' in the first place, which you either decrease (descend) or
increase (climb) ? Is it entered into an edit field in the form ?

If a class (Form1) has a reference variable (altitude), it must be
initialized (made to refer to a variable) in the class constructor's
initializer list.

For an example:

class MyForm1
MyForm1() : m_dReference(m_dValue) {}

double& m_dReference;
double m_dValue;

As you can see, the m_dReference is initialized in the constructor's list.
It is made to refer to the m_dValue variable. Changing the contents of
m_dReference or m_dValue reflects the changes to the other.

So, your problem is that your code has several bad errors. In order to help
you forward, you could try posting the entire header of your form class. The
link you posted didn't show the form picture, either.

-Antti Keskinen