how i will find type of variable from void *

how i will find type of variable from void *. cout return Pv on gcc-4.4.5 but i get original type on each iterator such as int, double etc. according iterartion
#include <stdio.h>
#include <vector>
#include<iostream>
#include <typeinfo>
#include<string>
using namespace std;

class Myclass{
public:
int ab;

};
int main(void) {
vector<void *> vec;
float k = 2.2;
int i = 100;
double d = 5;
Myclass myclass;
myclass.ab = 5;
vec.push_back(&i);
vec.push_back(&k);
vec.push_back(&d);
vec.push_back(&myclass);

vector<void *>::iterator it;
for ( it=vec.begin() ; it < vec.end(); it++ ){
void *y = *it;
cout << typeid(y).name() << endl;

}
I take it this is related to http://www.cplusplus.com/forum/general/42862/

The short answer is you can't; there is no way of knowing what the void* means.
I don't see why you would want to do it, either. Use templates instead.
Topic archived. No new replies allowed.