Beruflich Dokumente
Kultur Dokumente
A constructor with 4 integer parameters: initialize a 4D vector-object with particular values of its 4 attributes. It calls the constructor of the class vector.
2
A redefined method
p length to calculate the length of a vector .
Hint: Length = x2 + y 2 + z 2 + t2
A redefined method display to display a vector and its length on the screen.
Operation of the function main:
Create an array of 10 vector pointers.
For each pointer:
Ask users to enter a number 0 or 1, corresponds to 3D vector or 4D vector.
Ask users to enter values for the attributes of a 3D vector object (or 4D vector
object) to temporary variables.
Based on the information entered, initialize an appropriate object.
Use a f or loop to:
Display on the screen the information of 10 vectors and their lengths.