Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. g++ -c hasArray.cpp
  2. g++ -c Main.cpp
  3. g++ Main.o hasArray.o -o output
  4.  
  5. Undefined symbols for architecture x86_64:
  6. "hasArray::passPointer()", referenced from:
  7. _main in Main.o
  8. ld: symbol(s) not found for architecture x86_64
  9. clang: error: linker command failed with exit code 1 (use -v to see invocation)
  10.  
  11. #include <stdio.h>
  12. #include <iostream>
  13. #include "hasArray.hpp"
  14.  
  15. using namespace std;
  16.  
  17. int * passPointer(){
  18. cout << "Inside hasArrayn";
  19. int array[5] = {1,2,3,4,5};
  20. int * pointer = &array[0];
  21.  
  22. cout << "Array: ";
  23. for( int i =0 ; i < 3; i++)
  24. cout << array[i] << ", ";
  25. cout << "n";
  26. cout << "Pointer: " << pointer;
  27. return pointer;
  28. }
  29.  
  30. #ifndef _HASARRAY_H_
  31. #define _HASARRAY_H_
  32.  
  33. #include <stdio.h>
  34. #include <iostream>
  35.  
  36. class hasArray{
  37.  
  38. public:
  39. // hasArray();
  40. int * passPointer();
  41. };
  42.  
  43. #endif
  44.  
  45. #include <stdio.h>
  46. #include <iostream>
  47. #include "hasArray.hpp"
  48.  
  49. using namespace std;
  50.  
  51. int main(){
  52. cout << "Inside mainn";
  53. hasArray x;
  54. int * pointer = x.passPointer();
  55. cout << "Pointer: " << pointer << "n";
  56. cout << "Array: ";
  57. for( int i =0 ; i < 3; i++)
  58. cout << pointer[i] << ", ";
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement