Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define SIZE 10
- using namespace std;
- struct intArray {
- private:
- int a[SIZE];
- public:
- void set(int index, int value);
- void print();
- };
- void set(int index, int value) {
- if(index < SIZE)
- a[index] = value;
- else
- cout << "There was an error." << endl;
- }
- void intArray::print() {
- for(int i = 0; i < SIZE; i++)
- cout << "a[" << i << "] = " << a[i] << endl;
- }
- int main() {
- intArray num;
- for(int i = 0; i < SIZE; i++)
- num.set(i,i);
- num.print();
- cin.get();
- }
- error (L16): 'a' was not declared in this scope
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement