By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,305 Members | 1,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

Problem passing objects between functions

P: n/a
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;
Jul 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
tw*******@yahoo.com wrote:
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
Jul 22 '05 #2

P: n/a
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.********@comAcast.net> wrote in message news:<Gg************@newsread1.dllstx09.us.to.veri o.net>...
tw*******@yahoo.com wrote:
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

Jul 22 '05 #3

P: n/a
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.********@comAcast.net> wrote in message news:<Gg************@newsread1.dllstx09.us.to.veri o.net>...
tw*******@yahoo.com wrote:
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

Jul 22 '05 #4

P: n/a
On 18 Aug 2004 17:26:45 -0700 in comp.lang.c++, tw*******@yahoo.com
wrote,
decay * Da = new simpleSUSYdecay(ss,id1, id1 % 1000000);


Has ss.mN1 changed before this line? Has it changed after?
Jul 22 '05 #5

P: n/a
tw*******@yahoo.com wrote:

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.
--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.