#include <iostream>int foo(float* f, int* i){ *i = -1; *f = 0.0f; return *i;}int main(int, char *[]){ int i; //i = foo(reinterpret_cast<float*>(&i), &i); // 1 i = foo(new(&i) float, &i); // 2 std::cout << i << std::endl;}
#include <iostream>#if 0 // 0 - OK, 1 - UBtypedef float F;#elsestruct F{ int i; F(float v = 0.0f) { reinterpret_cast<float&>(i) = v; }};#endifint foo(F* f, int* i){ *i = -1; *f = 0.0f; return *i;}int main(int, char *[]){ int i; //i = foo(reinterpret_cast<F*>(&i), &i); // 1 i = foo(new(&i) F(), &i); // 2 std::cout << i << std::endl;}
*i = -1; *f = 0.0f;
C++ (Qt)float Rand( uint32 & seed ); QVector3D vec(Rand(seed), Rand(seed), Rand(seed));
void foo(std::shared_ptr<MyClass> c, int x);foo(std::shared_ptr<MyClass>(new MyClass), getXValue());