i want to initialize an array(set all elements to 0) . The array is to be used by different functions which r defined outside the class. obviously i cant initialize it in the class. and if i do it in a constructor or main(), it isnt recognised by all the functions outside the class using it.

what do i do ? where do i initialize the array. Please help. this is just the thing holding me back. :sad:

i want to initialize an array(set all elements to 0) . The array is to be used by different functions which r defined outside the class. obviously i cant initialize it in the class. and if i do it in a constructor or main(), it isnt recognised by all the functions outside the class using it.

Sure it is. You probably did it wrong if it's not working. Define what you mean by "it isnt recognised"

Sure it is. You probably did it wrong if it's not working. Define what you mean by "it isnt recognised"

if i initialize the array in main() or constructor, the other functions which use that array give error : 'array not defined'.

it shouldn't happen. try

#include <iostream>
int main () {
    int test [5]={0};
    cout<<test[0];
}

if i initialize the array in main() or constructor, the other functions which use that array give error : 'array not defined'.

Thats because they can't see the array or the array is out of scope for them. Post the code which displays this peculiar behaviour and we will see what can be done...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.