Having trouble with Constructor

Hi All,

I can't seem to understand why I am getting this error for the embedded code:

Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int <fileLocation> 18 matrix1

Would really appreciate if anyone could point out the mistake with my Constructor.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Element_1dline
{
private:
	int elementNumber;
	float elementArea;
	float k;
	float thickness;
	float w1;
	float w2;

public:
	float *areas;
	int elementLength;

	Element_1dLine(int mesh)
	{
		areas = new float[mesh];
	}

	void setNumber(int number1)
	{
		number1 = elementNumber;
	}
	int getNumber()
	{
		return elementNumber;
	}
};
Last edited on
You have written the name of the constructor function the wrong way. It has to be Element_ldline instead of Element_ldLine (I guess it's the class name that's wrong).

So the compiler thinks it's a normal member method and wants a return type, void int double ..., that's why you get this error message.
Topic archived. No new replies allowed.