Problem passing objects between functions

T

twizansky

Hello,

I have a problem with values of object properties changing seemingly
on their own. I am completeley baffled and would appreciate any
assistance.

specifically, I have a class called eetosfermions with the follwing
constructor:

eetosfermions::eetosfermions(int id1, int id2, SUSYspectrum & ss):
eetosparticles(id1, id2, ss, 1) { }

eetosfermions inherits from eetoapraticles which has the following
constructor:

eetosparticles::eetosparticles(int id1, int id2, SUSYspectrum & ss,
nFinal) {

cout << ss.mN1 << endl;
 
V

Victor Bazarov

I have a problem with values of object properties changing seemingly
on their own. I am completeley baffled and would appreciate any
assistance.

specifically, I have a class called eetosfermions with the follwing
constructor:

eetosfermions::eetosfermions(int id1, int id2, SUSYspectrum & ss):
eetosparticles(id1, id2, ss, 1) { }

eetosfermions inherits from eetoapraticles which has the following
constructor:

eetosparticles::eetosparticles(int id1, int id2, SUSYspectrum & ss,

Could it be you missed the '&' after one of 'SUSYspectrum' in any
of the two constructors? I am asking because it looks like you
typed the code here (instead of copying and pasting it) and you may
have corrected it inadvertently).
nFinal) {

What's the type of 'nFinal'? The absense of the type here leads to
my conclusion that you typed it in instead of copying.
cout << ss.mN1 << endl;
.
.
.

}

SUSYspectrum is a class with an 'double' property called mN1.

When I run the following code:

int main () {

SUSYspectrum S
.
.
// initialize S
.
.

cout << S.mN1 << endl;
eetosfermions p(1000012, -1000012, S);

}

I recieve the follwing output:
98.2857
6.36649e-314

The value of S.mN1 has changed without me doing anything! there is no
code between the two cout commands.

Does anyone have any idea what might be going on?

Not without seeing more (and real) code.

Victor
 
T

twizansky

Yes, I did type the code instead of cutting and pasting. Here is the
code, cut an pasted:

eetosfermions::eetosfermions(int id1, int id2, SUSYspectrum & ss):
eetosparticles(id1, id2, ss, 1) {}


eetosparticles::eetosparticles(int id1, int id2, const SUSYspectrum &
ss, int nFinal):
twototwomm(4,nFinal,0,0) {

cout << ss.mN1 << endl;
p1.fill(id1,ss);
p2.fill(id2,ss);
M1 = sqrt(norm(p1.M));
M2 = sqrt(norm(p2.M));
ID1 = p1.ID;
ID2 = p2.ID;
SS = ss;
string prname = "e- e+ -> " + p1.name + " " + p2.name;
name = copy(prname.c_str());
decay * Da = new simpleSUSYdecay(ss,id1, id1 % 1000000);
installDecay1(Da);
decay * Db = new simpleSUSYdecay(ss, id2, id2 % 1000000);
installDecay2(Db);
}


int main(){

SUSYspectrum S;

double tanbeta = 10.0;
double m2 = 200.0;
double r = 0.5;
double mu = 500.0;
double me1 = 130.0;
double me2 = 150.0;
double mq = 160.0;

S.generalSfermions(120.0, 300.0, tanbeta,
m2,r, mu, me1, me2, mq, 0.0);
S.fill();

cout << S.mN1 << endl;
eetosfermions P13a(1000012, -1000012, S);

}

twototwomm is a class from which eetosparticles inherits and which
itself inherits from a class called process. Here are the relevant
constructors:

twototwomm::twototwomm(int Ninitial, int Nfinal, double MM1,
double MM2): process(3, Ninitial, Nfinal), labvectors(2){
M1 = MM1;
M2 = MM2;
D1 = new nodecay(0,0);
D2 = new nodecay(0,0);
}

process::process(int N, int Ninitial, int Nfinal): n(N),
ninitial(Ninitial),
nfinal(Nfinal), cs(-1,1,-1,1), Camps(1,Ninitial,1,Nfinal){}

Thank you

Tommer
 
T

twizansky

Yes, I did type the code instead of cutting and pasting. Here is the
code, cut an pasted:

eetosfermions::eetosfermions(int id1, int id2, SUSYspectrum & ss):
eetosparticles(id1, id2, ss, 1) {}


eetosparticles::eetosparticles(int id1, int id2, const SUSYspectrum &
ss, int nFinal):
twototwomm(4,nFinal,0,0) {

cout << ss.mN1 << endl;
p1.fill(id1,ss);
p2.fill(id2,ss);
M1 = sqrt(norm(p1.M));
M2 = sqrt(norm(p2.M));
ID1 = p1.ID;
ID2 = p2.ID;
SS = ss;
string prname = "e- e+ -> " + p1.name + " " + p2.name;
name = copy(prname.c_str());
decay * Da = new simpleSUSYdecay(ss,id1, id1 % 1000000);
installDecay1(Da);
decay * Db = new simpleSUSYdecay(ss, id2, id2 % 1000000);
installDecay2(Db);
}


int main(){

SUSYspectrum S;

double tanbeta = 10.0;
double m2 = 200.0;
double r = 0.5;
double mu = 500.0;
double me1 = 130.0;
double me2 = 150.0;
double mq = 160.0;

S.generalSfermions(120.0, 300.0, tanbeta,
m2,r, mu, me1, me2, mq, 0.0);
S.fill();

cout << S.mN1 << endl;
eetosfermions P13a(1000012, -1000012, S);

}

twototwomm is a class from which eetosparticles inherits and which
itself inherits from a class called process. Here are the relevant
constructors:

twototwomm::twototwomm(int Ninitial, int Nfinal, double MM1,
double MM2): process(3, Ninitial, Nfinal), labvectors(2){
M1 = MM1;
M2 = MM2;
D1 = new nodecay(0,0);
D2 = new nodecay(0,0);
}

process::process(int N, int Ninitial, int Nfinal): n(N),
ninitial(Ninitial),
nfinal(Nfinal), cs(-1,1,-1,1), Camps(1,Ninitial,1,Nfinal){}

any suggestions are very welcome

Tommer
 
D

David Harmon

On 18 Aug 2004 17:26:45 -0700 in comp.lang.c++, (e-mail address removed)
wrote,
decay * Da = new simpleSUSYdecay(ss,id1, id1 % 1000000);

Has ss.mN1 changed before this line? Has it changed after?
 
K

Karl Heinz Buchegger

Yes, I did type the code instead of cutting and pasting. Here is the
code, cut an pasted:

Hard to tell.

Can you simplify your real program such that
* it still shows the error
* is small enough to post it here AND
can be compiled and run by one of us.

In other words: Post the complete program, but first
simplify it as much as possible such that we don't
have to wade through lots of code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top