خرید بک لینک

Vote count: 0

I have a class Stack three methods void append_item(int i), void pop_item(), and Result do_computation() const which retus something I'm interested in.

It is guaranteed that if I call

stack.append_item(1); Result result = stack.do_computation(); stack.pop_item();

on a Stack object it will be in exactly the same state as before. So if I put these three lines in a function, I'd want to pass the stack argument as a const Stack& knowing that it is save to do so and indicating that stack won't be modified.

However, append_item(int) caot be called on a const Stack.

Is this the right place to make use of the infamous const_cast? My major conce is clean design here.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 15 فروردين 1395 ساعت: 16:50

صفحه بندی