class CGoods
{
private:
char Name[21];
int Amount;
float Price;
float Total_value;
public:
void RegisterGoods(const char[], int, float);
};
void CGoods::RegisterGoods(const char name[], int amount, float price)
{
strcpy_s(Name, 21, name);
Amount = amount;
Price = price;
}
int main()
{
CGoods c1;
c1.RegisterGoods("C++", 12, 98.99);
return 0;
}
根据微软的解释,早期C++中,是允许修改this指针的
https://learn.microsoft.com/zh-cn/cpp/cpp/this-pointer?view=msvc-170
感谢🙏