1/* Copyright 2015-2020 Free Software Foundation, Inc. 2 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License as published by 5 the Free Software Foundation; either version 3 of the License, or 6 (at your option) any later version. 7 8 This program is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License 14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 16class A; 17static int get_values (const A& a); 18 19enum myenum {E_A = 10, E_B, E_C, E_D, E_E}; 20 21namespace N { 22 typedef enum {NA = 20, NB, NC, ND} ANON_NE; 23} 24 25namespace { 26 typedef enum {AA = 40, AB, AC, AD} ANON_E; 27} 28 29ANON_E g_e = AC; 30 31class A 32{ 33public: 34 typedef int ATYPE; 35 36 A () : public_ (1), protected_ (N::NB), private_ (3) {} 37 ATYPE public_; 38 static const myenum s_public_; 39 friend ATYPE get_values (const A&); 40 41protected: 42 N::ANON_NE protected_; 43 static N::ANON_NE s_protected_; 44 45private: 46 ATYPE private_; 47 static myenum s_private_; 48}; 49 50const myenum A::s_public_ = E_A; 51N::ANON_NE A::s_protected_ = N::NA; 52myenum A::s_private_ = E_C; 53 54static A::ATYPE 55get_values (const A& a) 56{ 57 A::ATYPE val; 58 59 val = a.public_ + a.private_; // 1 + 3 60 if (a.protected_ == N::NB) // + 21 61 val += 21; 62 if (a.s_public_ == E_A) // +10 63 val += 10; 64 if (a.s_protected_ == N::NA) // +20 65 val += 20; 66 if (a.s_private_ == E_C) // +30 67 val += 30; 68 if (g_e == AC) // +40 69 val += 40; 70 return val; // = 125 71} 72 73typedef int A::*PMI; 74 75int 76main () 77{ 78 A a; 79 int var = 1234; 80 PMI pmi = &A::public_; 81 82 return a.*pmi + get_values (a); // break here 83} 84