hi,
First off I'm very extremely new to C++, like...a few days or so, so I do have a lot of questions. But, here's where I'll start!
I am wondering if it is possible to have a pointer to an object? Similar to what you can do with structures. So that, when a new instance of the object is created, you can allocate the memory for it? For example, could you do this type of thing, assuming the class is already created in your code:
Would that be possible? I tried and when it returned one of the integers in my class, it was the wrong value. That is, instead of getting 50 back, I got: 3999000. Ugh...not 51, or 52, but 3999000, . but some other data was returned correctly, interestingly. I'm afraid to experiment too much because I'm afraid to write to something I shouldn't, accidently.Code:int main() { classname *ptr; ptr = new classname; // to provide sufficient memory ptr->function(param1, param2); /* to start of whatever function in the class */ delete ptr; return 0; }
So any help on this matter would be appreciated.
Brandon