The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > C / C++


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Tags: , ,

Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 11-19-2007, 08:22 AM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
What's arrow -> means in C++?

What is -> means in C++...? I know that it's not the way to call a method right...? thx

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 11-19-2007, 10:50 AM
Bacteria Bacteria is offline
Novice
Join Date: Nov 2007
Posts: 1
iTrader: (0)
Bacteria is on a distinguished road
well when you want to call a function using pointers you usde ->

Example :
We have a class Student
and this class has the function getstudentname();

in the main :
Code:
void main()
{
      Student s;
      Student *sptr;
 
sptr=&s;// sptr is pointing to all the functions of s
 
so we use :
sptr->getstudentname();
to use the function of s

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by TeraTask : 11-19-2007 at 10:57 AM. Reason: Added code tags
Reply With Quote
The Following 2 Users Say Thank You to Bacteria For This Useful Post:
HelloWorld (11-19-2007), TeraTask (11-21-2007)
  #3 (permalink)  
Old 11-19-2007, 10:57 AM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Staff*
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 416
iTrader: (0)
TeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enough
Bacteria: Please remember to use code tags.

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #4 (permalink)  
Old 11-21-2007, 12:19 PM
akshay_pirate akshay_pirate is offline
Novice
Join Date: Nov 2007
Posts: 2
iTrader: (0)
akshay_pirate is on a distinguished road
well buddy,-> operator is used when you want to use data members or member functions of a class using that class's object's pointer.
ex:


class C{
public:
int x;
void get(int a){
x=a;
}
};
void main(){
C c;
C *c1;
c1=c;

c1->a(3);
cout<<c1->x;
}

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #5 (permalink)  
Old 11-21-2007, 12:57 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Quote:
Originally Posted by akshay_pirate View Post
well buddy,-> operator is used when you want to use data members or member functions of a class using that class's object's pointer.
ex:


class C{
public:
int x;
void get(int a){
x=a;
}
};
void main(){
C c;
C *c1;
c1=c;

c1->a(3);
cout<<c1->x;
}
what's the difference with this then:

Code:
void main() {
 C c;
 c.a(3);
}

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #6 (permalink)  
Old 11-21-2007, 01:17 PM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Staff*
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 416
iTrader: (0)
TeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enough
For the difference between the . and -> operators, I suggest checking out Member Access Operators: . and -> (C++) . Essentially, the difference has to do with whether you're dealing with a pointer or not and needing to dereference.

Quote:
The –> operator dereferences the pointer. Therefore, the expressions e–>member and (*e).member (where e represents a pointer) yield identical results (except when the operators –> or * are overloaded).

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to TeraTask For This Useful Post:
HelloWorld (11-21-2007)
  #7 (permalink)  
Old 11-28-2007, 06:26 AM
akshay_pirate akshay_pirate is offline
Novice
Join Date: Nov 2007
Posts: 2
iTrader: (0)
akshay_pirate is on a distinguished road
no difference,both do the same work.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #8 (permalink)  
Old 11-30-2007, 04:24 AM
Bench Bench is offline
Full Programmer
Join Date: Jul 2007
Location: UK
Posts: 109
iTrader: (0)
Bench is on a distinguished roadBench is on a distinguished roadBench is on a distinguished roadBench is on a distinguished road
Just to add to this discussion - the -> operator is a short-hand way of writing (*foo).x where 'foo' is a pointer to a class/struct/union type.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

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



All times are GMT -7. The time now is 06:03 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50