-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hanks Homework, #9
base: master
Are you sure you want to change the base?
Conversation
#include <fstream> | ||
|
||
|
||
//input = std::cin , output = std::cout; Can this be done? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can put using std::cin;
and using std::cout;
up here and then just write cin and cout below.
@hankofwisdom what was an example of a statement where you were using auto with ifstream? |
@ninjapanzer it was the top comment I read the iostream class and it won't work |
cin is declared as as iostream and then applied to tie to bind it to the std stream. But I will have to try it later. |
So the reality is that C++ also includes a move constructor because streams like CIN cannot be copied. Move rebinds the internal std::Tie class to the new stream object. But it turns out there is a defect in how basic_streams are handled. That said by using = implies a copy constructor due to operator overloading. You might be used to languages that hide references and pointers behind variable names. Anything that is not a primitive is actually a reference so when you do auto ins = std::cin;
istream ins = std::cin; Both try to invoke the disabled copy constructor and thus fail because you can't copy a stream. Of course they provide a move method that is also basically disabled due to defect. Pointers do simplify this and here is an example of basically what every other pointer abstracting language does https://gist.github.com/ninjapanzer/aa9cdd6f0d6a34d1f0df |
#include <iostream> | ||
#include <fstream> | ||
|
||
std::string name = "",email = "",passcode = "",time_zone = "",file_path = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dangerous global variables that are not const could lead to data side-effects an difficult debugging. These should be within you main function or const.
Are we going to learn Pointers math
Why dose auto on an iostream make it an integer?