Need Helps wrote:
I get this:
error C2440: 'initializing' : cannot convert from 'class Day *' to 'class Day'
when I try to compile this:
Day d = new Day();
What is the reason for this? Thanks.
C++ != C#. :)
In C++, you must declare d a pointer:
Day* d = new Day;
d->whatever();
But unless you have a reason to create it dynamically, you're better off
declaring it as below:
Day d;
d.whatever();
This relieves you from worrying about the lifetime of the Day object, which
you must think about given that Day is a non-GC class per your error
message. The second form ensures that d is destroyed when it goes out of
scope.
--
Doug Harrison
Microsoft MVP - Visual C++