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
A PROGRAM TO CALCULATE AREA OF TRIANGLE

BACKGROUND: FILE SYSTEMS  In a computer, a file system (sometimes written filesystem) is the way in which files are named and where they are placed logically for storage and ret

Define the Data Types of c language? The C has a concept of 'data types' which are used to define a variable before its use and the definition of a variable will assign storage

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

C program for function  of average int average(int); void main() {           int max=0,c=0;           clrscr();           printf("ENTER THE LIMIT OF INPUT FOR AV

Write a function that computes f(x) for a quadratic polynomial in x, such as the one in assignment 3. Use the function to plot f(x) from -10 to +10.

Inbuilt Functions i).  Functions to manipulate strings The cstring library defines many functions to perform some manipulation operations with C-styled functions. The followi

Problem : (a) What do you understand by the term ‘constructor' in Java? Explain with an appropriate example. (b) Describe the differences between an object and a class usi

Explain the  bit fields portable or not? - No, Bit fields aren't portable. - As Bit fields can't span machine words and number of bits in a machine word is different on diff

A: No. There is nothing you can do in C++ which you cannot do in C. In spite of everything