+ 1
Please avoid writing a sentence in post tags, tags in forum has a different purpose https://code.sololearn.com/W3uiji9X28C1/?ref=app I can't quite expain it theoretically, but the error message says a default constructor for Usa_army class is needed. So I added a default constructor for Usa_army class, and off the error message go ...
10th Jan 2023, 7:29 AM
Ipang
+ 1
This code doesn't have any objects from this class defined, this code will not show anything on screen, and it will run, but the code inside the constructor functions will not execute. To show the values on screen you will have to create objects of classes and assign the values in constructor.
10th Jan 2023, 9:01 AM
Aditya Dixit
+ 1
Here is how you can create an object of class Usa_army and American_Navy and assign the values in constructor: int main() { Usa_army obj1(10, 20, 30, 40); American_Navy obj2(5, 8, 12, 20); return 0; } Also, the variable names a, b, c, d, n, s, y, and m in the constructor function could be more informative. A more semantically appropriate variable name makes it easier for others to understand the context of what's happening.
10th Jan 2023, 9:01 AM
Aditya Dixit