Skip to content

A class without constructor (or deleted constructor) can exist. #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion ch7/7.46.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
(a) A class must provide at least one constructor.

True. If the programmer doesn't provide any constructor, the compiler will synthesise one default constructor.
False.
This is valid code:
```
#include <iostream>

class C {
public:
C() = delete;
static int a;
};

int C::a = 1;

int main() {
std::cout << C::a << std::endl;
return 0;
}
```


(b) A default constructor is a constructor with an empty parameter list.

Expand Down