danielsbrewer
February 17th, 2003, 05:04 AM
Hi there I am pretty new to C++ object-orientated stuff and I was wondering if you could help. I have a class called Equations with a protected variable declared as:
valarray<double> myParameters;
I want to initialise this to a certain size during the constructor of the inherited class Model1. In the constructor I have:
valarray <double> myParameters(13);
myParameters[1]=2;
In another function of the Model1 class I have:
cout << myParameters[1] << endl;
But when this function is run it does not print "2" but some random amount. I concluded that i must be initialising it wrong.
Any ideas how to inherite a valarray object and initialise it to a certain size in the inherited class.
Thanks
valarray<double> myParameters;
I want to initialise this to a certain size during the constructor of the inherited class Model1. In the constructor I have:
valarray <double> myParameters(13);
myParameters[1]=2;
In another function of the Model1 class I have:
cout << myParameters[1] << endl;
But when this function is run it does not print "2" but some random amount. I concluded that i must be initialising it wrong.
Any ideas how to inherite a valarray object and initialise it to a certain size in the inherited class.
Thanks