I'm curious why the compiler doesn't complain if I hand over a const-pointer to a non-const-pointer as parameter in a constructor of a class that itself, which of course is at construction time not const.
#include <iostream>
class A
{
public:
    A(int* v) : v(v) {}
    int* v;
};
class B
{
public:
    B() : o(23), v(&o) {}
    const A cc() const
    {
        return A(v); //expected const to non-cosnt error here, but seems valid
    }
    int o;
    int* v;
};
int main() {
    B b;
    const B* bc = &b;
    A a = bc->cc();
    *(a.v) = 25; // here I'm changing an originally const value
    std::cout << b.o << std::endl;
    return 0;
}
With defining cc() as const I expected the line where the return value is initialized an error message about converting a const to a non-const. The code-snippet compiles fine and in the end I get the output "25" even so that should have been const.
 
     
     
    