| | |
Simple Varifacation please
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
I just wanted to make sure i am interperating code correctly when i write or read it when it comes to fstream.
when you say
ofstream example;
your basically making a keyword "example" to call different functions.
aka example.open()
or .close.
but, if i used example as the out put operator, i need a different name for ifstream.
So i could type
ifstream exampletwo;
And then use that "Keyword" to read from files that i write using the example keyword?
Does any of this make sense lol? Thanks
when you say
ofstream example;
your basically making a keyword "example" to call different functions.
aka example.open()
or .close.
but, if i used example as the out put operator, i need a different name for ifstream.
So i could type
ifstream exampletwo;
And then use that "Keyword" to read from files that i write using the example keyword?
Does any of this make sense lol? Thanks
>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
"Keyword" is a term already used to mean something else, so redefining it will only confuse you.
What you're doing is creating an variable of the ofstream class and calling it "example". You then invoke functions on that variable. Calling member functions can be confusing if you try to think about it too hard without knowing that
The object.method() form of calling member functions is pretty much just syntactic sugar for a more low level function call. It's the same thing with overloaded operators. When you say
Which is then in turn converted to a lower level function call:
From here, everything you've learned about functions can be applied to make the world a bit more consistent.
What you're doing is creating an variable of the ofstream class and calling it "example". You then invoke functions on that variable. Calling member functions can be confusing if you try to think about it too hard without knowing that
example.open ( "foo" ); essentially boils down to something like this: C++ Syntax (Toggle Plain Text)
ofstream_open ( example, "foo" );
cout<< 12345; , the compiler translates it into a member function call: C++ Syntax (Toggle Plain Text)
cout.operator<< ( 12345 );
C++ Syntax (Toggle Plain Text)
ostream_operator<< ( cout, 12345 );
I'm here to prove you wrong.
![]() |
Other Threads in the C++ Forum
- Previous Thread: Help needed filling array with unique random numbers
- Next Thread: Logic error, simple stat prog
| Thread Tools | Search this Thread |
api array based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






