What will happen if we increment a pointer to class which is typecasted to int type?
#include<bits/stdc++.h>
using namespace std;
class Hello{
int x=2;
int y=3;
public:
void print(){
cout<<"This is class Hello";
}
};
int main() {
Hello *h=new Hello();
int *i=(int *)h;
i++; //What will i point to?
}
My question is what does i point to once incremented as shown in the above code?
Also I have another doubt-I know memory to a structure in contigious fashion,Is memory assigned in contigious manner to class?
P.S:This question was asked to me in an interview with Toshiba Software