Non-pointer member function typedefs in C++? -


I would like to be able to use a single C ++ typed for both member function declarations and for them And the hints have been given if I can match the structure of non-member functions, then it would be right:

  #include & lt; Iostream & gt; X_ft = using char (int); // Forwarded the shared interface to advertise and implement X_ft foo; times; Four FU (int n) {return (n% 3 == 0)? 'A': 'B'; } Four times (int n) {returns (n% 5 == 0)? 'CD'; } Int main (int argc, char * argv []) {// Using the same type offiffe for the indicator as the above non-indicator X_ft * f {foo}; X_ft * const g {(argc% 2 == 0)? Bar: foo}; Std :: cout & lt; & Lt; F (RGC) & lt; & Lt; "," & Lt; & Lt; G (argc * 7) & lt; & Lt; Std :: endl; }  

I do not seem to be able to avoid semi-repetition type for nonstandard member functions:

  struct B {// Vi_f is not class-member-specific, despite using Vi_ft = void (int); Vi_ft baz, qux; // If possible, I do not want these unnecessary definitions using Vi_pm_ft = void (B :: *) (int); // 'decltype (& b :: baz)' is not a better IMO}; Zero B: False (Int N) {/ * ... * /} Zero B: CX (int n) {/ * ... *} Zero Efed (Bull X) {BB; B :: Vi_PM_FF {and B :: BAG}; // Any way modified B: Vi_F would be better. // SYNTAX from approved answer: B :: vi_ft B :: * g {x? & Amp; B :: baz: & amp; B :: qux}; // vi_ft should not be in B: B: Vi_FortB :: * H & B :: Falcon}, B :: I i & amp; B :: cx}; (B * f) (0); (B * g) (1); (B * h) (2); (B. * I) (3); }  

My actual code really can not use sidesteps like " auto F = & B :: foo; " everywhere, therefore I want to minimize my interface contract if possible, is there a valid syntax to name a non-indexed member function type? There is no trivial form of zero (B: :) (int) , zero (b :: and) ( etc.).

Edit: Approved Answer - Func_type class :: * I was missing the syntax. Thanks, guys!

The syntax you are searching for is vi_ft B :: * F .

  using vi_ft = void (int); Class B {public: vi_ft baz, qux; }; Zero B: False (int) {} Zero B: Quax (nti) {} zero Fried (bull x) {bb; Vi_ft B :: * f {x?} & Amp; B :: baz: & amp; B :: qux}; (B * f) (0); } Int main () {Fred (true); Fred (wrong); }  


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -