How to properly use a header file to be a complete class?

前端 未结 2 2249
萌比男神i
萌比男神i 2021-02-20 00:45

(Beginner programmer..) I\'m following the style of a header file that worked fine, but I\'m trying to figure out how I keep getting all of these errors when I compile. I am com

2条回答
  •  名媛妹妹
    2021-02-20 01:23

    That's a funny one. You are essentially killing your class name by #define Ingredient - all occurrences of Ingredient will be erased. This is why include guards generally take the form of #define INGREDIENT_H.

    You are also using name both for the member and the getter function (probably an attempt to translate C#?). This is not allowed in C++.

提交回复
热议问题