Message from C, C++ talks

June 2019

— Thank you for answer. But there is a problem when using delegating constructors. It's impossible to add anything else to class members initialization list. And so I decided to mix some already defined constructors and add remaining parameters in body. Is it a good approach?

Message permanent page

— Agree with Francisco, it looks OK, but list initialization usually is a better way (especially if you have many different constructors, and want them to be consistent).

Message permanent page

— I use delegating constructors a lot. If we had Python's syntax for function arguments, it would be different

Message permanent page

— Why is it impossible? Can you give an example that doesn't compile, but should in your opinion?


For example:

— Ah, I see, I thought it's possible 😅

— Several hours ago I was too :D

— Just to say, in my projects, the default constructor depends in other constructors, not the other way around. I think of it as "there should be a delegating constructor that can do the same job as the default one but with default parameters"

Message permanent page

— Sorry, can't get it. Can you show an example? Are you using default constructor as delegating? But it has no parameters.

Message permanent page

— What you're doing is printing the pointer to the file descriptor. It not what you want probably. I'm not familiar with C-way of reading files, but maybe this will be helpful.

Message permanent page

— It's stdio.h (standard I/O) not studio.h.

— /rules

— Click on the button to see the chat rules!

— I'm no expert, but I think you could reduce the verbosity in the member initializer lists by using default member initializers

Message permanent page

— Thanks, was thinking about it too.