c++ - Am I actually storing the object in the cpu register here? -
this question has answer here:
here in program using volatile register object, storing object register here?
why getting address of object 1
? please share thought on this.
#include <iostream> using namespace std; class a{ int i,j,k[999]; long double arr[9999999]; public: a(){ i=77; j=89; cout<<"\nctor\n"; } void disp()volatile { cout<<"\ni = "<<i<<" j = "<<j<<"\n"; // delete this; } ~a(){ cout<<"\ndtor\n"; } }; int main(){ register volatile *ao = new a; cout<<"address of = "<<ao; //out puts "1" me; (my processor core i3 330m). ao->disp(); delete ao; }
my thought: here might trying deny optimization of compiler pointer object ao
using volatile keyword, right? reason why got '1'! c++ standard says, if specify object or variable register
internally consider auto
. detaild info out put 1
see link
Comments
Post a Comment