class A { public: int value; A(): value(rand()) {} }; class B { public: void func(A &other) { Print(other.value); } }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnStart() { A a; B b; b.func(a); }
nicholi shen:
This is a completely different approach. I'd like it if you provided an explanation on it. See, I'm using a neural network library and it's classes take the form I posted above. Are the two methods different or the style used?
I'm thinking, you somehow coded the value variable to be assigned a value when the constructor is called. I don't clearly understand how that is getting done, and how this part
A a; B b; b.func(a);
gets the value to be printed.
Can this be done when more than one variable in the A class need to be accessed?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello there. I started with the code so it'd be easier to explain the problem.
As illustrated above, I'd like to print the value in CBase class called value, using the CClass but cannot figure out how.
I've tried this:
... and a whole bunch of other methods but I don't seem to be getting anywhere. I really need some help here.
Thanks in advance.