Use unnamed object to invoke method or not?
- by Chen OT
If I have a class with only only public method. When I use this class, is it good to use unnamed object to invoke its method?
normal:
TaxFileParser tax_parser(tax_file_name);
auto content = tax_parser.get_content();
or unnamed object version:
auto content = TaxFileParser(tax_file_name).get_content();
Because I've told that we should avoid temporary as possible. If tax_parser object is used only once, can I call it a temporary and try to eliminate it?
Any suggestion will be helpful.