Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > ifstream ofstream ?

Reply
Thread Tools

ifstream ofstream ?

 
 
Goran
Guest
Posts: n/a
 
      09-09-2011
On Sep 9, 5:05*pm, Stuart Redmann <(E-Mail Removed)> wrote:
> On 9 Sep., Goran wrote:
>
> > > > There's no reference in your code. Clearly, ifile is not a reference
> > > > (to a variable), it IS a variable.

>
> On Sep 9, Asger-P wrote:
>
> > > if it was an int or so I would have called it that, I just
> > > didn't know You used the same name for classes as well.

>
> On 9 Sep., Goran wrote:
>
> > What, you mean, like primitive/reference type in Java? Naaaaah... In
> > my mind, there's no such distinction in C++. "int" can pretty easily
> > be viewed as a class, only, it's full of operators .

>
> Gosh, I didn't know that the Java community used different names for
> variables depending on whether a variable is of a primitive type or of
> a class type.


I don't __know__ that they do (or how many of them). Please don't hold
me on that.

Goran.
 
Reply With Quote
 
 
 
 
Nobody
Guest
Posts: n/a
 
      09-10-2011
On Fri, 09 Sep 2011 17:07:25 +0200, Asger-P wrote:

> In my head "ifile" is the name that refer to the instance
> of the ifstream class, so it kind of an reference, of course
> I know it is not the "reference kind" reference, You see my
> problem.


In C and C++, you have primitive types (basically numbers; integer and
floating-point types), aggregates (structures, unions and, in C++,
classes), arrays, pointers and (in C++) references (which are basically
pointers under the hood).

In Java, you have primitive types and pointers (references) to class
types. You can't have a pointer to a primitive type, nor can you have an
instance of a class type other than via a pointer/reference.

Hence, class types tend to be referred to as reference types. Assignment
copies the reference, not the object to which it refers; for the latter,
you need to use the .clone() method.

Neither C nor C++ have this restriction. Pointers/references aren't
required for aggregate types, nor are they restricted to them.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Suddenly Can't Use "ifstream"s and "ofstream"s KevinSimonson C++ 4 11-04-2010 02:07 PM
ofstream * vs. ofstream Squid Seven C++ 5 07-14-2005 07:34 AM
ifstream / ofstream question (using libstdc++ v3) phoenix C++ 1 01-13-2005 04:39 PM
Problem which ifstream and ofstream class in VC++ Armando C++ 2 01-23-2004 03:50 PM
writes to files passed as struct of ofstream objects fail m vaughn C++ 0 07-11-2003 01:06 AM



Advertisments