Need a project done?

C++ Programming Developer

Search This Blog

Initialize Static Array in C++


Initialize Static Array in C++ program is given below:

#include <iostream>
using namespace std;

class myClass{
private:
static int array[100]; //Static Array in C++
public:
void display();
};
////////////////////////////////////////////////////////////////
int myClass::array[100] = {0}; //Initialize Static Array in C++

void myClass::display(){
for (int i = 0; i<100; i++){
cout << "array[" << i << "] = " << array[i] << endl;
}
}
//``````````````````````````````````````````````````````````````

int main(){
myClass obj;
obj.display();
return 0;
}
"Don't let anyone ever make you feel like you don't deserve what you want."