2 Replies - 165 Views - Last Post: 05 March 2013 - 05:57 PM Rate Topic: -----

#1 vickyp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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
"error C3861: 'dataV': identifier not found".
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  Icon User is online

  • Duke of Err
  • member icon

Reputation: 1329
  • View blog
  • Posts: 4,557
  • 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();


Was This Post Helpful? 1
  • +
  • -

#3 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3549
  • View blog
  • Posts: 10,993
  • 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.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1