1.11M Members

the difference between this two?

 
0
 
struct Information {
	ifstream* in;
	ofstream* out;
        ...
};
.....

((*info).in)->eof()  //this one

(*(*info).in).eof() // and this one

so, info is a Information struct, is there any different between the two shown above? my guess is they are the same. and what is "->" and "." called?

 
1
 

so, info is a Information struct

Those two lines are only meaningful if info is a pointer to an Information object.

is there any different between the two shown above?

Nope, the arrow operator is for convenience when dereferencing a pointer member.

and what is "->" and "." called?

They're the the arrow and dot operators. :)

 
0
 

You use the -> (pointer-to) operator to dereference a member of a pointer to an object/struct. You use the . (dot) operator to dereference a member of an object (not a pointer to the object), or a reference to an object. In your example, the operator * is what makes the change, in that it means something like "this is a reference to an object, not a pointer to the object). So, using the member "this" which is a pointer to the currently scoped object, you would use the pointer-to operator (->) such as "this->in", but if you use "*this" (which means a reference to the thing "this" points to), you would do "(*this).in". Confused yet? :-) This distinction between pointers and references is one of the things that causes the most difficulty for emerging C++ programmers.

 
0
 

You need to do some reading. This link will be helpfull C++ an hour a day
You should find the answer to alot of your questions there

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article