It is my understanding that there are a few ways to create objects in c++. The first way would be to just declare it (such as: "Date testDate(8, 23, 1989);" ), and that would create it on the stack.
The second way to do it is using the "new" operator, which puts it in the heap memory, and requires a pointer to access it. My question is, how would you call methods on an object stored in the heap memory?
I have a test class that stores the Date. One of it's methods is GetYear();. When i use this method on the variable stored in the stack, it works. But when i try to run it on the pointer, i get "Date.cpp:25: error: request for member ‘GetDate’ in ‘pDate’, which is of non-class type ‘Date*’".
Is there some special way i have to call a method on a pointer to get it to work? Or do i have to create a seperate method in the Date class that uses pointers?
basically you can either deference the object first then use the method call (first way) or use the arrow that deferences for you and does the method call
basically you can either deference the object first then use the method call (first way) or use the arrow that deferences for you and does the method call
I took this semester off, but am also doing computer science in college. I know java pretty well, but figured i would get a jump start on C++, as that will be coming up soon.