Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem passing objects between functions

twizansky@yahoo.com
Guest
 
Posts: n/a
#1: Jul 22 '05
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;

Victor Bazarov
Guest
 
Posts: n/a
#2: Jul 22 '05

re: Problem passing objects between functions


twizansky@yahoo.com wrote:[color=blue]
> 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,[/color]

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).
[color=blue]
> nFinal) {[/color]

What's the type of 'nFinal'? The absense of the type here leads to
my conclusion that you typed it in instead of copying.
[color=blue]
>
> 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?[/color]

Not without seeing more (and real) code.

Victor
twizansky@yahoo.com
Guest
 
Posts: n/a
#3: Jul 22 '05

re: Problem passing objects between functions


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


Victor Bazarov <v.Abazarov@comAcast.net> wrote in message news:<GgMUc.61$Ae.28@newsread1.dllstx09.us.to.veri o.net>...[color=blue]
> twizansky@yahoo.com wrote:[color=green]
> > 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,[/color]
>
> 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).
>[color=green]
> > nFinal) {[/color]
>
> What's the type of 'nFinal'? The absense of the type here leads to
> my conclusion that you typed it in instead of copying.
>[color=green]
> >
> > 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?[/color]
>
> Not without seeing more (and real) code.
>
> Victor[/color]
twizansky@yahoo.com
Guest
 
Posts: n/a
#4: Jul 22 '05

re: Problem passing objects between functions


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


Victor Bazarov <v.Abazarov@comAcast.net> wrote in message news:<GgMUc.61$Ae.28@newsread1.dllstx09.us.to.veri o.net>...[color=blue]
> twizansky@yahoo.com wrote:[color=green]
> > 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,[/color]
>
> 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).
>[color=green]
> > nFinal) {[/color]
>
> What's the type of 'nFinal'? The absense of the type here leads to
> my conclusion that you typed it in instead of copying.
>[color=green]
> >
> > 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?[/color]
>
> Not without seeing more (and real) code.
>
> Victor[/color]
David Harmon
Guest
 
Posts: n/a
#5: Jul 22 '05

re: Problem passing objects between functions


On 18 Aug 2004 17:26:45 -0700 in comp.lang.c++, twizansky@yahoo.com
wrote,[color=blue]
> decay * Da = new simpleSUSYdecay(ss,id1, id1 % 1000000);[/color]

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


Karl Heinz Buchegger
Guest
 
Posts: n/a
#6: Jul 22 '05

re: Problem passing objects between functions


twizansky@yahoo.com wrote:[color=blue]
>
> Yes, I did type the code instead of cutting and pasting. Here is the
> code, cut an pasted:
>[/color]

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.


--
Karl Heinz Buchegger
kbuchegg@gascad.at
Closed Thread