#include <iostream>
#include <string>
using namespace std;
class Box {
// attributes
public:
int size = 1;
string type;
Box(int size, string type) {}
};
int main() {
Box e(2, "b");
int b = e.size;
cout << b;
}
I know I can get what I want by setting the parameters in the constructor as new_size
and new_type
then just setting size
equal to new_size
and etc but how come this doesn't work?
When I create the object e
and use the constructor parameters am I not setting size
equal to 2
and type
equal to "b"
?