Today we will:
Implementation of header files
matrix multiplication in C++
- Header files are used in OOP for C++, to blue print structures.
- When creating class structures c++ you will need to use a header file for other files to reference.
- They describe the class structure, not how.
Why do we use them?
- From C programming, uses similar compile methods for its program.
How we do it?
- First two lines and last line are the same in all your files
- If the header file hasn’t been defined move to the second line and define the thing.
- Rest of the statement describes what we expect to see in the class.
- Inside the class example there will be a number of private and public things.
- End of the header file
Example in .cpp
- Set and get name.
Test. cpp File
- include all of the libraries from the previous sections
- what the complier looks for, so we must star with it.
- Create a string called uName
- Instantiate an example – Make an object of that class
- Then we ask what the user’s name is
- User provides name and we hold it in the holding variable
- Then we send a message out saying Hello and the name that was stored.
- Take some input and some output
float sniperPositions4, firstPositionTransition, hold;
- Instantiation of 3 float matrices
- hold matrices needs to be the same as the sniperPosition.
- Next four lines is all the values for the safe areas different areas
- Next lines are for all the values possible.
- Making hold value 0 each time
for (int i=0 ….
- Printing out the initial safe values for the snipper locations (as a way to compare to )
- Refer to the position in the holding matrix and we add to that position the first value in sniper position with the first position transition value. (Doing the matrix multiplication)
running the code