Article 55401 C++ constructor

C++ constructor

by
Jerry Mcguire
from LinuxQuestions.org on (#55401)
It sounds simple enough when trying to open a file or to test the existence of a file.

Code:{
std::ifstream f("filename");
if (f) {
// file exists
}
}My question is, what is f when "filename" does not exist? To do the same in my own classes, how to write the constructor that returns that "null" object?latest?d=yIl2AUoC8zA latest?i=_VO0iGWE_fw:fzVy_XqabJQ:F7zBnMy latest?i=_VO0iGWE_fw:fzVy_XqabJQ:V_sGLiP latest?d=qj6IDK7rITs latest?i=_VO0iGWE_fw:fzVy_XqabJQ:gIN9vFw_VO0iGWE_fw
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments