Professional Documents
Culture Documents
Sample Question For Quiz1 PDF
Sample Question For Quiz1 PDF
Be informed that this is just a sample, not necessarily the pattern of the actual question
Consider the following main(). You need to write the FULL CLASS along with necessary member data and member
functions. You also need to write global functions, if any. Your program should be able to execute the given main().
class Computer{
//data: manufacturerName, speedInGigaHartz, ramInGB;
public:
//write default constructor
//write parameterized constructor
//add other necessary member functions...
//declare necessary friend functions...
};
int main(){
Computer *ptr; //represent an array of Computer objects
int n; //no of computers
populateComputers(ptr, n, rand()%n);
//write this global function
// this function allocates memory for n Computer objects to ptr and default
// constructor is automatically fired for them. Now you have to overwrite
// the default values of first m no of computers (m is 3rd parameter)
// by using cin>>ComputerObject format in a loop.
cout << “Detail of the computers having input-ed info are: “ << endl;
for(i=0; i<n ;i++) cout << ptr[i] << endl;
// the operator function should not print default info if not initialized