Fill This Form To Receive Instant Help
Homework answers / question archive / Practice Questions Classes & Objects Can a class data type include variables? o Yes o No Can a class data type include functions? o Yes o No Variables declared in a class data type are called ______________________
Practice Questions
Classes & Objects
Write a code segment of main() that creates an instance of each data type and assigns a value to the entry.
new Employee;
new Employee(10);
class Person
{
public:
void print(ostream& out);
private:
int age;
float weight;
int id;
};
void Person::print(ostream& out)
{
//what goes here?
}
class Item { public: Item(int, float); static int get_size() const; float get_cost() const; void set_size(int); void set_cost(float); private: static int size; float cost; }; |
|
class Item { public: Item(); Item(int, float); static int get_size() const; float get_cost() const; void set_size(int); void set_cost(float); private: static int size; float cost; }; |
|
class Wine { private: int age; float cost; public: Wine(); int get_age(); float get_cost(); }; |
|
class Wine { private: int age; float cost; public: Wine(); int get_age(); float get_cost(); }; |
|
class Wine
{
public:
Wine();
int get_age();
double get_cost();
private:
int age;
double cost;
}
Wine bottle;
int main() {
ClassA obj1;
ClassB obj2;
return 0;
}
int main() {
ClassA obj;
ClassA* p = new ClassA;
delete p;
return 0;
}