Pointer declaration for data member, C/C++ Programming

Pointer declaration for data member: Method 1:

int M::* px; // This is known as pointer-to-member declared for class member of A.

px = &M::x;//The pointer px is pointing to the data member m in the class A. int S1;

S1=m.*px; 

Method 2: M *pm; pm=&m; int M::*py; py=&M::y; int S2;

S2=pm->*py;//pointer-to-object->*pointer-to-member function

Posted Date: 9/20/2012 8:02:43 AM | Location : United States







Related Discussions:- Pointer declaration for data member, Assignment Help, Ask Question on Pointer declaration for data member, Get Answer, Expert's Help, Pointer declaration for data member Discussions

Write discussion on Pointer declaration for data member
Your posts are moderated
Related Questions
Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Is always the default constructor for Fred Fred::Fred()?

Write in a file: void main() { int i,j,k,l,list[1000]; FILE *fp; char any[8];   cout cin >> any;   fp = fopen(any,"wb");     for(j=0;j     {

Write a function that has a single int parameter n and returns an int: 0 if n is negative, otherwise 1. You are not allowed to simply check the integer value, and should use the fu


processing two jobs through 2 machine

Verifone pos offline mod vx670 Project Description: I want a programmer who will build custom application for Offline VX670 to collect and save info+pin 1) Press the am


A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

give an example of function