Initializing 2d Vectors in the constructor

I have a class with two 2D vectors declared private like this
1
2
3
4
5
6
7
private:
	char ans;
	int row,columns;
	string command;
	vector<vector<double> >MAT;
	vector<vector<double> >RESULT;
}


Then when I'm trying to initialize the two vectors in the constructor I get an error, I've done this before but for the life of me I just can't remember what I did to make this work

1
2
3
4
5
6
7
Transpose::Transpose()
:MAT(55,vector<double>(5)),
RESULT(5,vector<double>(5))
{
	row = 0;
	columns = 0;
}


gives the following errors


transpose.cpp:29: error: new types may not be defined in a return type
transpose.cpp:29: note: (perhaps a semicolon is missing after the definition of ‘Transpose’)
transpose.cpp:29: error: return type specification for constructor invalid


anyone?
1
2
3
4
5
6
7
class someclass
{
private:
	std::vector<std::vector<double> > i;
public:
	someclass():i(3,std::vector<double>(3)){std::cout<<"Success";};
};

This works for me. Are you sure you put a semi-colon after all your class declarations? I think the error lies elsewhere.
ohh god you're right, how could I have been so blind, it was telling me the whole time "transpose.cpp:29: note:(perhaps a semicolon is missing after the definition of ‘Transpose’)"

Thank you very much :D
Topic archived. No new replies allowed.