1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <iostream> 17 18 static const uint32_t IP_IDA = 10; 19 static const uint32_t IP_IDB = 20; 20 static const uint32_t IP_IDC = 30; 21 22 using namespace std; 23 class Adder { 24 public: Adder(int i=0)25 explicit Adder(int i = 0) 26 { 27 totalRes = i; 28 } AddNum(int numberRes)29 void AddNum(int numberRes) 30 { 31 totalRes += numberRes; 32 } GetTotal()33 int GetTotal() 34 { 35 return totalRes; 36 } 37 private: 38 int totalRes; 39 }; main()40int main() 41 { 42 Adder a; 43 a.AddNum(IP_IDA); 44 a.AddNum(IP_IDB); 45 a.AddNum(IP_IDC); 46 cout << "Total " << a.GetTotal() << endl; 47 return 0; 48 }