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
#include #include #include #include #include class Employee { private: char *Name; //Set them as pointers... int IdNumber; char *Department; char *Position; public: voi

Explain protected, public, private in C++? These are three access spaecifiers in C++. - Public - Here data members and functions are accessible outside the class. - Pr

There are ''n'' ants on a ''n+1'' length rod. The ants are numbered from 1 to n and are initially placed at positions starting from position 1 till position n. They are moving eith

There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that

Here is a program that uses an inline function to compute and return the absolute value of its input argument. # include inline int abs(int x) {                  ret



1.1 A Few Notes: 1. Please test your program with various inputs prior to submission. 2. All group members must understand the entire project for interactive grading. Equal

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of t

The purpose of this assignment is to familiarize you with the notion of encapsulation as well as some aspects of IP and ICMP. Write your programs in C or C++. They will be grade