<SOLVED><HELP> error type

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <iomanip>
using namespace std;

//class_matrix.cpp
class matrix
{
	private:
		int column;
		int row;
		fraction** mtx;
	public:
		matrix (int r = 0, int c = 0);
		~matrix ();
		int getColumn ();
		int getRow ();
		fraction getEntry (int, int);
		void setEntry (int, int, fraction);
		void displayEntry (int, int);
		void display ();
};

//class_fraction.cpp
class fraction
{
	private:
		int num;
		int denum;
	public:
		fraction (int a = 0, int b = 0);
		~fraction () {};
		int getNum ();
		int getDenum ();
		void setNum (int);
		void setDenum (int);
		fraction simplify (fraction);
		fraction addFrac (fraction, fraction);
		fraction mulFrac (fraction, fraction);
		fraction subFrac (fraction, fraction);
		fraction divFrac (fraction, fraction);
		void display();
};

//mtxmanip.cpp
bool mtxcheck_add (int, int, int, int);
bool mtxcheck_mul (int, int);
float mtxadd (matrix, matrix);
float mtxmul (matrix, matrix);

//intmanip.cpp
int gcd (int, int);


those are my code..
and these are the error report for my header file..

1>------ Build started: Project: Matrices, Configuration: Debug Win32 ------
1>Build started 9/15/2012 10:10:43 PM.
1>InitializeBuildStatus:
1> Touching "Debug\Matrices.unsuccessfulbuild".
1>ClCompile:
1> struct_fraction.cpp
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(12): error C2143: syntax error : missing ';' before '*'
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(18): error C2146: syntax error : missing ';' before identifier 'getEntry'
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(18): warning C4183: 'getEntry': missing return type; assumed to be a member function returning 'int'
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(19): error C2061: syntax error : identifier 'fraction'

can help me tell what is wrong with this..@@
Last edited on
Order.
`matrix' uses `fraction', so it must be defined before.
I can't tell from what you posted what is in header files and what is in .cpp files or if the line numbers in the errors messages correspond with the line numbers of what you posted.

1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(12): error C2143: syntax error : missing ';' before '*'
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

The compiler doesn't like something on line 12 of mainlib.h.
Now it just so happens that line 12 of what you posted is a reference to fraction, but based on the order of what you've posted, fraction has not yet been declared.


1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(18): error C2146: syntax error : missing ';' before identifier 'getEntry'
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(18): warning C4183: 'getEntry': missing return type; assumed to be a member function returning 'int'
1>c:\users\wawaunion\documents\visual studio 2010\projects\matrices\matrices\mainlib.h(19): error C2061: syntax error : identifier 'fraction'

Here again at lines 18 and 19 you reference fraction, but fraction has not yet been declared.

Put the declaration of fraction BEFORE the declaration of matrix.


thanks..!!
it is working.. haha.. the error is very simple.. never notice bout the alignment..
Topic archived. No new replies allowed.