I am very very new to C++, and I am trying to create a math engine
I have a class called Point, and objects from this class need to be able to hold an unknown amount of dimension values. I have a variable called DAmount that is decided when a point is created. I want to have a method that takes DAmount, and creates that many variables connected to the Point object.
For example, I declare a Point named "SixDPoint" and then set its DAmount to 6. I then use a method named CreateDVars to create six variables connected to the object "SixDPoint". I can then use these six variables to act as XYZ+ axises.
I have no idea how to do this. Here is some code to explain what I am trying to do. Thanks so much
#include <iostream>
using namespace std;
class Point
{
public:
int DAmount;
void CreateDVars(int)
{
//Variable declaration Function
}
};
int main()
{
Point SixDPoint; //declaring a Point named SixDPoint
SixDPoint.DAmount = 6; // this sets the dimension amount, of SixDPoint, to 6
SixDPoint.D1 = 1;
SixDPoint.D2 = 1;
SixDPoint.D3 = 1;
SixDPoint.D4 = 1;
SixDPoint.D5 = 1;
SixDPoint.D6 = 1;
//this should assign all six dimensions of SixDPoint, to 1
cout << SixDPoint.D1 << "/n";
cout << SixDPoint.D2 << "/n";
cout << SixDPoint.D3 << "/n";
cout << SixDPoint.D4 << "/n";
cout << SixDPoint.D5 << "/n";
cout << SixDPoint.D6 << "/n";
//this should print out all of the coordinates of SixDPoint
return 0;
}