Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Intermediate
Sep 15, 2000

The standard functions isalpha(), isdigit(), isprint() etc., defined in the stan

The .* and ->* operators enable you to call a member function without having to know the function's name. Remember, however, that when using these operators, you have to parenthesize the expression as follows:

 
A a; // create object
void (A::*pmf)() = &A::f; // create pointer to member

// the two pairs of parentheses are needed here:
(a.*pmf)(); // call A::f() thorough pointer to member

Omitting the first pair of parentheses, as in the following example, is a common mistake:

 
a.*pmf(); // error, missing parentheses

Although some compilers might accept it, this is not the correct C++ syntax. Always use two pairs of parentheses when calling a member function through either .* or ->*.

Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap