0

So I'm working on a C++ project, and came across this overloaded constructor that functioned perfectly, but I don't quite understand why it's functioning correctly. The n(n) confuses me altogether, and I'd prefer if that information was within the overloaded constructor itself. What is this actually accomplishing?

Overloaded constructor:

caesarCipher::caesarCipher(int n) : n(n) {}

Default constructor:

caesarCipher::caesarCipher()
{
    n = 1;
}
  • https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list – eerorika Sep 22 '20 at 16:39
  • 1
    `n(n)` is... nasty. But the outer `n` refers to the member `n` and the inner `n` refers to the parameters. It would be a lot easier to read as `caesarCipher::caesarCipher(int nVal) : n(nVal) {}` – Mike Vine Sep 22 '20 at 17:05

0 Answers0