Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2d vector declaration compile error

Status
Not open for further replies.

skata

Programmer
Oct 25, 2002
7
US
I am using g++ on a sun OS machine and am getting a compile error when I declare this 2d array in the private member data of a class:

vector<double> c(0);
vector<vector <double> > mat(0, c);

matrix.h:43: 'vector' is used as a type, but is not defined as a type.
matrix.h:44: `vector' was not declared in this scope
matrix.h:44: syntax error before `>' token

Anyone know whats going on here?
 
This compiles for me.
Code:
vector<double> c;
vector< vector<double> > mat(0,c);

make sure you have the space between '>' '>'characters right?

vector< vector<double>[red]space[/red]> mat(0,c);

-pete
 
Include
#include <vector>
and
using namespace std;
and try again...
 
If you don't want to use

using namespace std;

you'll have to use

std::vector<double> c;
std::vector< std::vector<double> > mat(0,c);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top