.h file

Can anyone tell me if the following .h file is ok ?

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
#ifndef PROGRAM1
#define PROGRAM1

            cMatrix();

            ~cMatrix();

            void MatrixOne();

            void MatrixTwo();

            void MultMatrixTogether();



            int r1,r2,r3,r4,r5,r6,r7,r8,r9;

            int m1,m2,m3,m4,m5,m6,m7,m8,m9;

            int matrix[3][3];

            int matrix1[3][3];

            int matrix2[3][3];

           


#endif  
Line 6: A destructor without a class.
Lines 16 and 18: Looks to me like an array could be used here.

Am I correct in assuming the whole piece is supposed to be inside a class/struct?
yes
it is a body of class


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
#ifndef PROGRAM1
#define PROGRAM1

            cMatrix();

            ~cMatrix();

            void MatrixOne();

            void MatrixTwo();

            void MultMatrixTogether();



           

            int matrix[3][3];

            int matrix1[3][3];

            int matrix2[3][3];

            int r1,r2,r3,r4,r5,r6,r7,r8,r9;

            int m1,m2,m3,m4,m5,m6,m7,m8,m9;


#endif   



how can I fix the destructor ?
Last edited on
Well, you can start by actually adding the class there.
Do you mean like ?


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
#ifndef PROGRAM1
#define PROGRAM1


class cMatrix

{

      public:

            cMatrix();

            ~cMatrix();

            void MatrixOne();

            void MatrixTwo();

            void MultMatrixTogether();

 

      private:

            int r1,r2,r3,r4,r5,r6,r7,r8,r9;

            int m1,m2,m3,m4,m5,m6,m7,m8,m9;

            int matrix[3][3];

            int matrix1[3][3];

            int matrix2[3][3];

 

};

char ch;

#endif   




One variable is in the main
char ch one
Last edited on
That's better.

If ch is not needed anywhere else, make it local to main(). Avoid global variables whenever possible.
do I have to include int main() in it ?
What do you mean? Just do this:
1
2
3
4
5
6
//...
};

//char ch; //(Moved from here...)

#endif    

1
2
3
4
5
//...
int main(/*...*/){
	char ch; //(...to here.)
	//...
}
thank you !
I got it
Last edited on
Topic archived. No new replies allowed.