If you come from Java, then it would be much easier for you to stick to "pointers" like BaseObject* bobj2, because they actually operate the way you know instances in Java. You can live long time without using a single C++ "object", which does not have similar equivalent in Java.
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
Hi,
I come from Java background so apologies if this question is obvious to c/c++ peeps. I have two objects BaseObject and SecondObject . SecondObject is initialised with a parametrised constructor containing BaseObject or in this world a pointer/reference not the object itself like i do in java. My problem is when i do this i cannot let a local object (to secondobject) instance = the passed in reference or contents of passed in reference. I have to extract the value and set that = to locala variable e.g. localobject = passedInreferenceToObject; is BAD localVAriable= passedInreferenceToObject.getValueOfSomething() is GOOD
My question is why can i not do this? Is it possible to initialise another copy of the passed in object reference?