Hello

I'm working on my MS thesis and I want to use some value from a variable in
channel.cc , this variable return the Pr and Pt , power of receiver and
power of transmitter respectively. so i defined a variable ("getvalue_")
and a function (getvalue) in channel.h (channel header file) in this way:

[channel.h :]

class WirelessChannel : public Channel {
 ....
public:
...
WirelessChannel(void);
double getvalue_;
inline double getvalue() {return getvalue_;}
....
}

and also in channel.cc ,call the variable and equal it to the function that
desire to read   :

[channel.cc]

void
WirelessChannel::calcHighestAntennaZ(Phy *tifp)
{
...
getvalue_ = wifp->getPt();
printf("P_t____ = %f\n",getvalue_);
...
}
it's noticable that getvalue_ is printed in channel.cc
but when call the function getvalue in AODV.CC
[AODV.cc]
{
....
void
AODV::recvRequest(Packet *p) {
...
WirelessChannel *tifp;
double x=tifp->gethighestAntennaZ();
printf("x____ = %f\n",x);
double y=tifp->getvalue();
printf("y____ = %f\n",y);
...
     }

the value of x is printed in terminal but
but for the getvalue function segmentation fault occur.

what should i do to read a variable from other cc files? which part of
above i was wrong that segmentation fault happened?

Thanks in advance for your help.



______________________________________________________

Alireza Shamsoshoara, M.Sc.

Faculty of Electrical and Computer Engineering (ECE)

K.N.Toosi University of Technology

Tehran, IRAN.

Reply via email to