PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 20, 2022

[FIXED] How to specify member pointer to an array element?

 October 20, 2022     arrays, c++, data-members, pointers     No comments   

Issue

I have a library with function, which looks like this:

template<typename S1> void NastyFunction(S1 *array, EntryType S1::* member1);

So if I have an array of structs like:

struct TData {
  float a;
  float b[10];
};

TData dataArray[N];

I can apply NastyFunction to all a-s in dataArray using:

NastyFunction( dataArray, &TData::a );

How to apply this NastyFunction to all for example b[7]-s in dataArray?


Solution

You can't. While the entire array is a member of the class, its individual elements are not, so there is no way to make a member pointer point at them.



Answered By - Angew is no longer proud of SO
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing