I'm writing a program that will let you create a faux database. Basically I want to use dynamic memory to let users create arrays of objects with properties they define.
I've run into an issue that I don't fully understand, though, so I thought I'd ask for a little help : )
I want to declare an object as a pointer (because later I'll make the object into a new array with a variable in its index), and let the user change the value of one of the properties. Here's the code:
#include <iostream>
#include <string>
usingnamespace std;
struct props{
char numval[10];
char altval[10];
};
class DataObj{
public:
props * numprop;//this will become an array which contains properties that house number values
char DataName[10];//the name of the data can't be longer than 10 letters//
props * altprop;//this will become an array which contains the different properties.
};
int main()
{
cout << "Type in the name of the objects you want to collect data on(for example, \'Books\' or \'Cars\')\n\n\t";
DataObj * Entry;
cin >> (*Entry).DataName;
//the code goes on from here, but this is where the runtime error occurs.//
So is it just that you can't change the properties of a pointer? It compiles perfectly. It's just that a runtime error crashes it after the user changes the value of the DataName property.