I am attempting to try out composition, so a class has an object of another class as a member.
In the case below, Glum has an object Fabulous.
I get the following error regarding the purposeful C style pointer though. Appreciate I can use string instead, but I would like to know why I get the warning message, error: incompatible types in assignment of ‘constchar*’ to ‘char [20]’ for the code below.
A few other problems:
Line 8: You reference cout, but you have neither std:: nor using namespace std;
Line 18: You declare the second argument as const. However, at line 25, the second argument is non-const. Your compiler should have complained about this,
Line 18: You can't have a defaulted argument to the left of a non-defaulted argument.
Line 22,25: You don't specify default syntax on a constructor implementation.
Line 34: It's pointless (and wrong) cast a quoted literal to a non-const pointer. Most compilers store quoted literals in a read only portion of memory. If you tried to modify what the non-const pointer points to, you would get an access violation.
Line 37: You're trying to instantiate Glum with three arguments. You have no constructor that accepts three arguments.