daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest May 8th, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // main.cpp
  2.  
  3. #include <iostream>
  4. #include "SomeObject.h"
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.  
  11.     SomeObject someObj;
  12.  
  13.     vector<int> & vec = someObj.getSomeVectorReference();
  14.  
  15.     cout << vec.size() << endl;
  16.     return 0;
  17. }
  18.  
  19. // SomeObj.cpp
  20.  
  21. #include "SomeObject.h"
  22.  
  23. using namespace std;
  24.  
  25. SomeObject::SomeObject()
  26. {
  27.     //ctor
  28. }
  29.  
  30. SomeObject::~SomeObject()
  31. {
  32.     //dtor
  33. }
  34.  
  35. vector<int> & SomeObject::getSomeVectorReference()
  36. {
  37.     vector<int> returnVec;
  38.  
  39.     for (int i = 0; i < 10; i++)
  40.         returnVec.push_back(i);
  41.  
  42.     return returnVec;
  43. }
  44.  
  45. // SomeObj.h
  46.  
  47. #ifndef SOMEOBJECT_H
  48. #define SOMEOBJECT_H
  49.  
  50. #include <vector>
  51.  
  52. class SomeObject
  53. {
  54.     public:
  55.         SomeObject();
  56.         virtual ~SomeObject();
  57.  
  58.         std::vector<int> & getSomeVectorReference();
  59.  
  60.     protected:
  61.  
  62.     private:
  63. };
  64.  
  65. #endif // SOMEOBJECT_H
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top