Hi, I'm currently revising for my C++ exam and I'm going through past papers and I'm stuck on the very first question, can someone explain this to me, I feel like a n00b! The question is:
1. a) Define a Vector2D class encapsulating two real-valued coordinates of a vector on a two-dimensional plane. Use the most compact real type for representation. Include a constructor and appropriate scalar selector methods.
P.S. I don't think I've gone through the Vector2D class yet, I've only studied vector class a little bit.
#include "Vector2D.hpp"
int main( int args, char * argv[] )
{
// create a vector from the origin to the point (3,5)
Vector2D vector( 3, 5 );
return 0;
}
I think helios misunderstood - it is a vector of real-valued coordinates, not a vector-of-vectors. Much like a 2D point.
My bet is that you are asked to define a class that contains two real-valued coordinates, say x and y. In C++ you have a choice of two built-in types for real-number representation, and you must use the one that takes up the least memory of them.
You must do a constructor that initializes the two real-number values. The "appropriate scalar selector methods" i don't know about - get/set methods?
@ Seymour: Please do not give away answers like this. If a man is hungry, give him a net and teach him to fish, don't just give him a fish!