returning a vector of type double from a function

Page 1 of 1

2 Replies - 241 Views - Last Post: 05 March 2013 - 05:57 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=314437&amp;s=5b0b2aaa65988119173d238c89cf81a6&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 vickyp

Reputation: 0
• Posts: 3
• Joined: 05-March 13

returning a vector of type double from a function

Posted 05 March 2013 - 05:17 PM

Hello, The error I am getting is
I thought it was because I was doing
vector<double> test1 = dataV();
but even on separate lines the problem still
occurs?? I appreciate any help.

```#include <vector>
#include <iostream>
#include <sstream>

using namespace std;

int main(){

vector<double> test1;
test1 = dataV();

return 0;
}

vector<double> dataV(){

vector<double> any ;

return any;
}

```

Is This A Good Question/Topic? 0

Replies To: returning a vector of type double from a function

#2 #define

• Duke of Err

Reputation: 1732
• Posts: 6,158
• Joined: 19-February 09

Re: returning a vector of type double from a function

Posted 05 March 2013 - 05:44 PM

When a function is called the compiler requires some information about the function beforehand.

You can either declare the function before the function is called, or declare the head of the function before the call (often called a function prototype).

So this function prototype could be placed before the main function.

```vector<double> dataV();

```

#3 Skydiver

• Code herder

Reputation: 4768
• Posts: 15,750
• Joined: 05-May 12

Re: returning a vector of type double from a function

Posted 05 March 2013 - 05:57 PM

You should have also gotten a warning before the error that would have hinted at the problem. Hopefully this has taught you not to ignore compiler warnings.