Do C++ struct also call constructors (default, copy constructors) and destructors just like classes or they follow the C language guidelines for struct? So in the example below, is a default constructor called?
Foo structObject; \\Foo is a struct
Yes, they do. The only difference between struct
and class
in C++ is in visibility of it's members. Struct
has by-default members public, class
private.
Effectively, writing
class A {
public:
//// ...
}
is the same as writing
struct A {
//// ...
}