| | |
Can I return Vector from Virtual Function
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2008
Posts: 25
Reputation:
Solved Threads: 0
Hi,
I was curious if I could return a vector from a virtual function. I keep getting an error for this.
Can anyone tell me what I am doing wrong?
I was curious if I could return a vector from a virtual function. I keep getting an error for this.
C++ Syntax (Toggle Plain Text)
Class A { public: virtual vector<int> getSomeStuff(); private: } .cpp File vector<int> A::getsomeStuff() { return; }
Can anyone tell me what I am doing wrong?
misspellings mostly
C++ Syntax (Toggle Plain Text)
class A { public: virtual vector<int> getSomeStuff(); private: }; vector<int> A::getSomeStuff() { vector<int> ay; return ay; } int main() { }
•
•
Join Date: Dec 2007
Posts: 360
Reputation:
Solved Threads: 69
I prefer
to avoid a possible copy on return.
C++ Syntax (Toggle Plain Text)
void A::getSomeStuff(vector<int> & vec) { ... }
to avoid a possible copy on return.
If you are forced to reinvent the wheel at least try to invent a better one!
Please use code tags - Please mark solved threads as solved
Please use code tags - Please mark solved threads as solved
![]() |
Similar Threads
- Runtime Error - R 6025 - pure virtual function call (Windows NT / 2000 / XP)
- Vector and virtual function questions (C++)
- STL funciton return vector of map iterators (C++)
Other Threads in the C++ Forum
- Previous Thread: Good and Bad Habits?
- Next Thread: No error But wrong Output. Why??
Views: 286 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






