i need help :(:(.

  • Thread starter Thread starter den.NET
  • Start date Start date
D

den.NET

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.dotnetforums.net/showthread.php?t=91020 ).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!!!!

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

altitude=altitude-descendaltitude;
}


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

HOW CAN I INITIALIZE THAT REFERENCE IN CONSTRUCTOR BASE/MEMBER
INITIALIZER LIST?
THANK U FOR YOUR CONSIDERATION.
 
"den.NET" <[email protected]>
wrote in message
[Much irrelevant matter excised.]
double & altitude; [and more]
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;

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
write:
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.
 
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.
but the problem is :
d:\c++\samples\lbox\list\Form1.h(311): error C2530: 'altitude' :
references must be initialized

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.
please the experienced users,help me.HOW CAN I INITIALIZE THAT
REFERENCE "altitude"? i dont find it,if u know please tell me.

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 ?
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

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.
HOW CAN I INITIALIZE THAT REFERENCE IN CONSTRUCTOR BASE/MEMBER
INITIALIZER LIST?

For an example:

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

private:
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
 
Back
Top