Table of Contents
struct
in C++?struct
members?void vector_init(Vector& v, int s) {
v.elem = new double[s];
v.sz = s;
}
new
operator in C++?.
and ->
operator in C++?struct Vector {
double* elem;
int sz;
};
void f(Vector v, Vector& rv, Vector* pv) {
v.sz = 10;
rv.sz = 20;
pv->sz = 30;
}
int main() {}
struct
in C++, the compiler may introduce padding between members. Given a struct like the following:
struct Example { char a; int b; char c; };
class
instead of a struct
change memory layout?