//c++ code(通过测试)
#include <iostream>
using namespace std;struct Rectangle{
Rectangle(int width, int height)
{
this->width = width;
this->height = height;
}
int width;
int height;
};
int main()
{
Rectangle *rec = new Rectangle(5,6);
cout<<rec->width<<endl;
cout<<rec->height<<endl;
return 1;
}
具体的区别这里就不说明了,直接看代码
本文展示了一个使用 C++ 编写的结构体 Rectangle 的简单示例。该示例定义了一个包含宽度和高度属性的结构体,并通过指针创建了一个结构体实例。程序输出了实例的宽度和高度值。
436

被折叠的 条评论
为什么被折叠?



