How To Use sizeof an Operator in C++
Free C++ course with real-time projects Start Now!!
Program 1
// Program for Sizeof Operator #include<iostream> #define clrscr() system("cls") using namespace std; class Test1 { private: double d1; double d2; double d3; int n; }; class Test2:public Test1 { }; int main() { clrscr(); Test1 T1; Test2 T2; cout<<"size of class Test1 : "<<sizeof(T1); cout<<"\nsize of class Test2 : "<<sizeof(T2); // int a=34; // cout<<"\nsize of integer "<<sizeof(a); // cout<<"\nsize of double "<<sizeof(34.67); // cout<<"\nsize of float "<<sizeof(34.67f); // cout<<"\nsize of char "<<sizeof('y'); return 0; }
Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google