我必须构建一个具有两种数据类型的程序(过程 C++)。一个叫做 Elem,它是 vector (一维数组)的一个元素。一个叫做 Vector,它包含一个 unsigned int 来表示数组的大小以及 Elem 本身的数组。我似乎无法找出正确的方法来构造这些,以便它们工作,因为我以前从未对过程 C++ 做过任何事情。
这是我的
typedef Elem {
float Element;
}
typedef Vector {
unsigned int size = 0;
Elem* Array = new array[];
}
但是我收到了这个错误
C++ requires a type specifier for all declarations
typedef Elem {
~~~~~~~ ^
还有
error: expected ';' after top level declarator
typedef Elem {
^
我在这里不知所措,我们将不胜感激!
最佳答案
关于c++ - typedef 如何代替 Procedural c++ 的 struct/class?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40323933/