by Dinesh Thakur Category: Classes in C++

 

#include <iostream.h>

#include<conio.h>
class powers
{
    int x;
         public:
                      powers()
                   {
                      x=0;
                      cout << "\nno initializer\n\n";
                   }
                      powers(int n)
                  {
                      x=n;
                      cout <<"\n\ninitializer:"<< x;
                   }
                      int getx() { return x; }
                      void setx(int i) { x =i; }
 };
          void main()
      {
          clrscr();
          powers ofTwo[] = {1, 2, 4, 8, 16}; // initialized
          powers ofThree[5]; // uninitialized
          getch();
      }

Call Class Constructor Or Not During Class Array Declaration



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles