473,385 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem passing objects between functions

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
5 1349
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
33
by: abs | last post by:
Hi all. My list: <ul> <li id="a" onclick="show(this)">Aaaaaaaa</li> <li id="b" onclick="show(this)">Bbbbbbbb</li> <li id="c" onclick="show(this)">Cccccccc <ul> <li id="d"...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
3
by: waheed azad | last post by:
Hi, I have a been developing an accounting system for a non-profit organization. I had decided to to divide the solution, in three layers, presentation, business layer and database layer. ...
6
by: cppnow | last post by:
Hello. I have a strange conceptual problem I'm trying to think about. I would like to build a library that allows the user to do the following: 1) User defined types: The user defines their...
3
by: Subodh | last post by:
Hi All, In C++ we could pass a constant reference to a function so that the target function could not modify the objects passed eg. const classA & dummmyfunction(const classB) similar thing...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.