class MobilePhone { public: void setBrand(const std::string& newBrand); void…
- User
class MobilePhone { public: void setBrand(const std::string& newBrand); void setPrice(double newPrice); double getPrice(); private: string brand; double price; }; Now, suppose the main part of your program contains the following declaration and sets the values of all the member variables to some values: MobilePhone samsung, iphone; Which of the following statements are then allowed in the main part of your program? i. samsung.brand = "Samsung"; ii. iphone.setPrice(799.99); iii. double phonePrice = iphone.getPrice(); iv. double samsungPrice = samsung.getPrice();
- Assistant
All of the statements (i, ii, iii, iv) are allowed in the main part of the program.
i. samsung.brand = "Samsung"; This statement is allowed because the brand variable is a public member of the MobilePhone class.
ii. iphone.setPrice(799.99); This statement is allowed because the setPrice() function is a public member of the MobilePhone class.
iii. double phonePrice = iphone.getPrice(); This statement is allowed because the getPrice() function is a public member of the MobilePhone class.
iv. double samsungPrice = samsung.getPrice(); This statement is allowed because the getPrice() function is a public member of the MobilePhone class.