Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #define SIZE 10
  3.  
  4. using namespace std;
  5.  
  6. struct intArray {
  7. private:
  8. int a[SIZE];
  9. public:
  10. void set(int index, int value);
  11. void print();
  12. };
  13.  
  14. void set(int index, int value) {
  15. if(index < SIZE)
  16. a[index] = value;
  17. else
  18. cout << "There was an error." << endl;
  19. }
  20.  
  21. void intArray::print() {
  22. for(int i = 0; i < SIZE; i++)
  23. cout << "a[" << i << "] = " << a[i] << endl;
  24. }
  25.  
  26. int main() {
  27. intArray num;
  28.  
  29. for(int i = 0; i < SIZE; i++)
  30. num.set(i,i);
  31. num.print();
  32.  
  33. cin.get();
  34. }
  35.  
  36. error (L16): 'a' was not declared in this scope
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement