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
What if attributes of the object are non-public? How would implementation change? Would I have to make "getter" and "setter" methods or is there another way?
It will not change at all. - private or protected only means the access is limited to the inside of the scopes class, or (protected) its inheriters.
I see, yes. I think your point is clear. But it should not be such a "dirty" hack. - Wouldnt it be better to stick to good practice when showing a solution. It might lead someone else to have false impressions on how to do things. - Especially when they cannot "subtract" the dirt from a shown code...
You are right.
Originally I suggested an initializer method, like "Create" in "ChartObjects" or "Controls" classes in the standard library.
It will not change at all. - private or protected only means the access is limited to the inside of the scopes class, or (protected) its inheriters.
Okay, so I tried to follow your advice and made the two following methods:
Then I tried to run this code again:
I get the same errors as before. However, if I do something like this:
This works just fine and I confirmed the Print statement runs. What is the problem with the second block's declaration
Okay, so I tried to follow your advice and made the two following methods:
Then I tried to run this code again:
I get the same errors as before. However, if I do something like this:
This works just fine and I confirmed the Print statement runs. What is the problem with the second block's declaration
Could youshow the whole code, all relevant code. - I can only guess right now. - You do not have a parametric constructor. - Whats the compiler error?
EDIT:
Why is your copy constructor empty?
Queue(const Queue<T> queue){}
At least do this then:
Queue(const Queue<T>& queue){ operator=(queue); }
If you do above, you should change the signature of the operator=() to this:
Could youshow the whole code, all relevant code. - I can only guess right now. - You do not have a parametric constructor. - Whats the compiler error?
EDIT:
Why is your copy constructor empty?
At least do this then:
If you do above, you should change the signature of the operator=() to this:
See the original post for all the relevant code and error strings. In terms of what is under "Work," currently it is nothing, and correction to the code that was shown, the methods should take in a reference of queue (of course, since anything else would be an error).
Could youshow the whole code, all relevant code. - I can only guess right now. - You do not have a parametric constructor. - Whats the compiler error?
EDIT:
Why is your copy constructor empty?
At least do this then:
If you do above, you should change the signature of the operator=() to this:
Instead of this:
He is trying to do this:
q = Queue<double>(20);
Try this.
Try this.
I know you can do this, but say you did not know 20 was the max size of q and just want a general initialization
Queue<double> q;
Then assign q to be a Queue of 20 without adding a resize method (which is bad practice, since other generic classes don't have this workaround and resizing to 20 doesn't reset the variable).
EDIT: Is "Queue<double>(20)" bad syntax? If so, what is the equivalent?
I know you can do this, but say you did not know 20 was the max size of q and just want a general initialization
Then assign q to be a Queue of 20 without adding a resize method (which is bad practice, since other generic classes don't have this workaround and resizing to 20 doesn't reset the variable).
EDIT: Is "Queue<double>(20)" bad syntax? If so, what is the equivalent?
You have to use pointer.
I know you can do this, but say you did not know 20 was the max size of q and just want a general initialization
Then assign q to be a Queue of 20 without adding a resize method (which is bad practice, since other generic classes don't have this workaround and resizing to 20 doesn't reset the variable).
EDIT: Is "Queue<double>(20)" bad syntax? If so, what is the equivalent?