Hi, I'm supposed to write a code for this question
Write C++ class declaration for a class called Vector3D and a code for handling 3 dimensional vector (V=Vx i + Vy j + Vz k ). The initial values for (Vx ,Vy and Vz) will be passed as parameters to the constructor. If there are not given, a default value of 0 is to be used.
Use operator overloading for
Adding two vectors : V3 = V1 + V2
Subtracting two vectors V3 = V1 - V2
Dot product: V3 = V1 * V2
Compound Assignment: V1+=V2
Insertion Operator (<<) to print the vector: cout<<V1
Extraction Operator (>>) to read the vector: cin>>V1
This is my code:
#pragma once
#include<iostream>
using namespace std;
class Vector3D
{ private: double Vx, Vy, Vz;
A few questions,if you please.
Firstly, is the code correct?
Secondly, I think I haven't done the dot product correctly, as if I didn't put the class name in the declaration it would also be considered as operator overloading or not?
Finally, the only error occurred was 1>LINK : fatal error LNK1561: entry point must be defined
1>
1>Build FAILED.
PS. Am not allowed to change anything in the main function.