Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- g++ -c hasArray.cpp
- g++ -c Main.cpp
- g++ Main.o hasArray.o -o output
- Undefined symbols for architecture x86_64:
- "hasArray::passPointer()", referenced from:
- _main in Main.o
- ld: symbol(s) not found for architecture x86_64
- clang: error: linker command failed with exit code 1 (use -v to see invocation)
- #include <stdio.h>
- #include <iostream>
- #include "hasArray.hpp"
- using namespace std;
- int * passPointer(){
- cout << "Inside hasArrayn";
- int array[5] = {1,2,3,4,5};
- int * pointer = &array[0];
- cout << "Array: ";
- for( int i =0 ; i < 3; i++)
- cout << array[i] << ", ";
- cout << "n";
- cout << "Pointer: " << pointer;
- return pointer;
- }
- #ifndef _HASARRAY_H_
- #define _HASARRAY_H_
- #include <stdio.h>
- #include <iostream>
- class hasArray{
- public:
- // hasArray();
- int * passPointer();
- };
- #endif
- #include <stdio.h>
- #include <iostream>
- #include "hasArray.hpp"
- using namespace std;
- int main(){
- cout << "Inside mainn";
- hasArray x;
- int * pointer = x.passPointer();
- cout << "Pointer: " << pointer << "n";
- cout << "Array: ";
- for( int i =0 ; i < 3; i++)
- cout << pointer[i] << ", ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement