Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C + + ONLY PLEASE Write the class declaration for a class named Animal that has the following member variables and member functions. Only the
C ONLY PLEASE
Write the class declaration for a class named Animal that has the following member variables and member functions. Only the
member functions should be public. The two member variables should be called name string and age int Member functions
should be named setValues, and display. you could have more variablesfunctions in reality, but not needed here
Default constructor: should set name to be none and age to be none and are default values to both member var
Overloaded constructor: should accept appropriate parameters for both name and age.
Destructor: should set all member variables to their default values, and display a message Animal left
The setValues function should have no return and two input parameters for both name and age. The function should store the
parameters in both age and name. This is a mutator function
The display function is an accessor function, it should have no return type or parameters. It should output to the screen a line
similar to "Animal: name is age years old but using the values stored in the member variables eg Animal: cat, is years
old
There should be two files involved, Animal.h and Animal.cpp
Write your complete program Animal.h file here: pts
Continuing with the previous problem, write your complete program Animal.cpp file here: pts
Continuing with the previous problem, given the following pointer, dynamically allocate an array of objects. Use the pointer to
set all three objects values to be the values provided in the table, and then display all the values stored in the array. pts
Animal ptr;
Name Age
cat
tiger
wildcat
Given the following binary file, pts each
double var;
long s sizeofvar;
Predict the output and explain your answer briefly:
file.seekgs ios::beg;
file.readreinterpretcast&var;
sizeofvar
cout var;
file.seekgs ios::cur;
file.readreinterpretcast&var;
sizeofvar
cout var;
file.seekgs ios::end;
file.readreinterpretcast&var;
sizeofvar
cout var;
Declare a structure named Student which has the following three member
a cstring of chars name an int for ID a double for GPA pts
Continuing with the previous problem Declare an object called freshman which is instantiated from Student. Ask user to enter
all corresponding information. A name may contain space. pts
Continuing with the previous problem. First, open a binary file name recorddat Use the structure and freshman object
declared above; write freshman objects data to the binary file. Close the file by the end. pts
Continuing with the previous problem. Read the file that was created in problem file is already opened assuming you do not
know how many records there are, read from file and then display all records on console. pts
Predict the output, and explain your answer briefly or with a diagram pts each
Program segment Your output and explanation
int i;
int p &i;
int p &i;
p;
p;
p;
p;
cout p;
char s;
char p "Final Exam Day";
s &p;
cout s endl;
int p;
int array
;
p array;
cout p endl;
p;
cout p endl;
p ;
cout p endl;
p;
cout p endl;
p &array;
cout p endl;
pts Given the following cstring, write a function that capitalizes all the letters.
char str hello world!
after calling your function, str becomes:
HELLO WORLD!
void capitalizestr char str
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started