type conversion

/*
The type remains unchanged after type coercion
*/
#include "stdafx.h"
#include <iostream>
#include <thread>
#include <ctime>
#include <Windows.h>
#include <typeinfo>
using namespace std;
intmain()
{
	int* p1 = new int;
	void* p2;
	cout << "The type of p1 is " << typeid(p1).name() << endl;
	cout << "The type of p2 is " << typeid(p2).name() << endl;
	double* p3 = (double*)p1;
	cout << "The type of p3 is " << typeid(p3).name() << endl;

	int a = 1;
	double b = (int)a;
	cout << "The type of a is " << typeid(a).name() << endl;
	cout << "The type of b is " << typeid(b).name() << endl;
	cout << "The type of a is " << typeid(a).name() << endl;
	
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324647518&siteId=291194637