Simple Varifacation please

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2008
Posts: 111
Reputation: clutchkiller is an unknown quantity at this point 
Solved Threads: 1
clutchkiller's Avatar
clutchkiller clutchkiller is offline Offline
Junior Poster

Simple Varifacation please

 
0
  #1
Dec 1st, 2008
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
>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!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,590
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 710
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Simple Varifacation please

 
0
  #2
Dec 1st, 2008
"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 example.open ( "foo" ); essentially boils down to something like this:
  1. ofstream_open ( example, "foo" );
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 cout<< 12345; , the compiler translates it into a member function call:
  1. cout.operator<< ( 12345 );
Which is then in turn converted to a lower level function call:
  1. ostream_operator<< ( cout, 12345 );
From here, everything you've learned about functions can be applied to make the world a bit more consistent.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 111
Reputation: clutchkiller is an unknown quantity at this point 
Solved Threads: 1
clutchkiller's Avatar
clutchkiller clutchkiller is offline Offline
Junior Poster

Re: Simple Varifacation please

 
0
  #3
Dec 1st, 2008
I get it. What you just said helped me peice it all together in my head. Thanks a lot!
>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!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC