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;
}
No comments:
Post a Comment