We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,318 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

the difference between this two?

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?

4
Contributors
3
Replies
14 Hours
Discussion Span
1 Year Ago
Last Updated
4
Views
wildplace
Junior Poster in Training
72 posts since Dec 2009
Reputation Points: 10
Solved Threads: 4
Skill Endorsements: 0

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. :)

deceptikon
Challenge Accepted
Administrator
3,499 posts since Jan 2012
Reputation Points: 822
Solved Threads: 481
Skill Endorsements: 58

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.

rubberman
Posting Maven
2,682 posts since Mar 2010
Reputation Points: 378
Solved Threads: 316
Skill Endorsements: 53

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

ejosiah
Junior Poster
196 posts since Feb 2008
Reputation Points: 72
Solved Threads: 23
Skill Endorsements: 3

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0929 seconds using 2.69MB