0% found this document useful (0 votes)
19 views

A A A A: Const Const

This document provides instructions for an object-oriented programming lab assignment to create a Vector class. The Vector class will represent 3D vectors with attributes i, j, and k of double type. Constructors and getter/setter/display functions are described. Member functions for calculating vector length, dot product, cross product, addition, and subtraction are also outlined. The main() function will create Vector objects, take user input, perform selected operations, and display results.

Uploaded by

Lovely Jutt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

A A A A: Const Const

This document provides instructions for an object-oriented programming lab assignment to create a Vector class. The Vector class will represent 3D vectors with attributes i, j, and k of double type. Constructors and getter/setter/display functions are described. Member functions for calculating vector length, dot product, cross product, addition, and subtraction are also outlined. The main() function will create Vector objects, take user input, perform selected operations, and display results.

Uploaded by

Lovely Jutt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Object Oriented Programming

Lab 05
Topic Covered: Returning Objects and Objects Passing By Reference

Q1. Make a Vector class that represents a 3D vector

 It has three attribute


 i, j and k as double data type.
 Make no argument constructor to set
 All attributes equal to zero.
 Make three arguments constructor that takes
 First argument and saves it into i.
 Second argument and saves it into j.
 Thirds argument and saves it into k.
 Make void Get() functions to get data for attributes of this
class.
 Make void Show() function to display these attributes on screen.
Like this: < 3, 4, -6 >
 Make double Mod() function to calculate and return length of a
vector.
| A|=√ A 2i + A2j + A2k
 Make double Dot(const Vector& B) const function to calculate and
return dot product of two vectors.
| A ∙ B|= Ai Bi+ A j B j + A k Bk
 Make Vector Cross( const Vector& B) const function to calculate
and return cross product of two vectors. This function will be
called in main() like this:
C = A.Cross(Vector B);

i j k

|
| A × B|= Ai
Bi
Aj
Bj |
Ak
Bk

1
 Similarly
 Make Vector Sub( const Vector& B) const to subtract two
Vector objects
 Make Vector Add( const Vector& B) const to add two Vector
objects
 Remember to write functions declaration inside the class and
functions definition outside the class.
 Also make three separate files Vector.h, Vector.cpp and main.cpp
 Make three Vector objects in main() and call these functions to
check their working.
 In the main function take inputs for two vectors from user
 Ask the user what type of operation he/she wants to perform.
 Apply that operation and show the answer on screen.

Here is the output of program

You might also like