Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // main.cpp
- #include <iostream>
- #include "SomeObject.h"
- using namespace std;
- int main()
- {
- SomeObject someObj;
- vector<int> & vec = someObj.getSomeVectorReference();
- cout << vec.size() << endl;
- return 0;
- }
- // SomeObj.cpp
- #include "SomeObject.h"
- using namespace std;
- SomeObject::SomeObject()
- {
- //ctor
- }
- SomeObject::~SomeObject()
- {
- //dtor
- }
- vector<int> & SomeObject::getSomeVectorReference()
- {
- vector<int> returnVec;
- for (int i = 0; i < 10; i++)
- returnVec.push_back(i);
- return returnVec;
- }
- // SomeObj.h
- #ifndef SOMEOBJECT_H
- #define SOMEOBJECT_H
- #include <vector>
- class SomeObject
- {
- public:
- SomeObject();
- virtual ~SomeObject();
- std::vector<int> & getSomeVectorReference();
- protected:
- private:
- };
- #endif // SOMEOBJECT_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement