Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22260

Debugger fails to show return value of function taking vector in C++

$
0
0

I've this C++ program, when I run the debugger it fails to show the return value of the f1.

screenshot

#include <iostream>#include <vector>#include <string>using namespace std;string f1(vector<int> v) {    return "this takes in a vector\n";}string f2(int x[]) {    return "this takes in an array\n";}int main() {    vector<int> vec = {1, 2, 3};    string x = f1(vec);    cout << x;    int arr[] = {1, 2, 3};    string y = f2(arr);    cout << y;}

When I run the program, both f1 and f2 execute as expected, and I see the correct output.

However, when I debug the program:
The debugger evaluates the return value of f2(arr).
The debugger fails to show the return value of f1(vec).


Viewing all articles
Browse latest Browse all 22260


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>