Top "Static-cast" questions

A C++ cast operator to convert from one type to another, using only information about the static type of the object being cast

Accessing subclass members from a superclass pointer C++

I have an array of custom class Student objects. CourseStudent and ResearchStudent both inherit from Student, and all the instances …

c++ inheritance virtual-functions dynamic-cast static-cast
c++ static_cast and references

struct A{}; struct B : A{}; int main() { A a; A& a_ref = a; static_cast<B>(a); // *1 …

c++ static-cast
C++ static_cast runtime overhead

See the code below. a) Does, in this case (simple inheritance, no virtual members), the static cast in B::df() …

c++ runtime overhead static-cast
Why is this static_cast not allowed?

I have an object of class A that I want to allocate on a custom stack object. To do this, …

c++ visual-c++ c++11 static-cast
C++ difference between adding const-ness with static_cast and const_cast of "this" object?

As per Scott Meyers, to prevent repetition of code in the const version of a getter and the non-const version …

c++ static-cast const-cast
When is static cast safe when you are using multiple inheritance?

I found myself in a situation where I know what type something is. The Type is one of three (or …

c++ dynamic-cast static-cast
Can static_cast turn a non-null pointer into a null pointer?

I need to write code for a callback function (it will be called from within ATL, but that's not really …

c++ visual-c++ pointers static-cast
C++ static_cast from int* to void* to char* - can you help me to understand this code?

I'm a beginner in C++, and I have problem with understanding some code. I had an exercise to do, to …

c++ static-cast
What is the difference between static_cast and Implicit_cast?

What is implicit_cast? when should I prefer implicit_cast rather than static_cast?

c++ boost static-cast boost-implicit-cast
Can I cast an unsigned char* to an unsigned int*?

error: invalid static_cast from type ‘unsigned char*’ to type ‘uint32_t* {aka unsigned int*}’ uint32_t *starti = static_cast&…

c++ memory-management static-cast