Hey, Im a beginner and i have some issues with this program. This program takes 2 boxes and calculate the volume of the box and prints it to the screen.
I have included a constructor and some get/set functions. I have some issues with ERROR. The errors is: C2228 and expression must have class type
But you don't have that constructor. You can default it:
Box() = default;
There are lots of other errors and warnings:
In function 'int main()':
33:7: error: request for member 'setheight' in 'Box2', which is of non-class type 'Box()'
34:7: error: request for member 'setlength' in 'Box2', which is of non-class type 'Box()'
35:7: error: request for member 'setwidth' in 'Box2', which is of non-class type 'Box()'
42:38: error: request for member 'volumen' in 'Box2', which is of non-class type 'Box()'
In member function 'void Box::setwidth(double)':
55:2: error: 'width' was not declared in this scope In member function 'double Box::getwidth()':
65:9: error: 'width' was not declared in this scope
In constructor 'Box::Box(double, double, double)':
68:54: error: class 'Box' does not have any field named 'width'
23:9: warning: 'Box::height' will be initialized after [-Wreorder]
21:9: warning: 'double Box::length' [-Wreorder]
68:1: warning: when initialized here [-Wreorder] In member function 'double Box::volumen()':
71:16: error: 'width' was not declared in this scope In member function 'double Box::getwidth()':
66:1: warning: control reaches end of non-void function [-Wreturn-type] In member function 'double Box::volumen()': 72:1: warning: control reaches end of non-void function [-Wreturn-type]
Some of them are typos, your IDE should help there.
In your constructor, initialise the variables in the same order as they are in the class definition.