Question

Program C++ (use visual studio) Q1. What default copy constructor does the compiler insert in the...

Program C++ (use visual studio)

Q1. What default copy constructor does the compiler insert in the following class?

class Student {

string name;

string id;

double grade;

};

===========================

Q2 .What is the factor transfer method used when the f() function is called from?

void f(int n[]);

int main() {

int m[3]= {1, 2, 3};

f(m);

}

==================================

Q3. Write a program that produces a bigger() with a prototype as shown below and outputs a large value by inputting two integers from the user. Bigger() returns true or false if a given factor is equal to a, b, and passes the large number to big.

[ bool bigger(int a, int b, int& big); ]

program code:

Homework Answers

Answer #1

Q.no.1:

The default copy constructor the compiler insert in the given Student  class is

Student( Student &N) { Name = N.Name ; id = N.id ; grade = N.grade ; }

//Where Student is the default copy constructor function name

//The Student inside the parenthesis is an object of the Student class and it stores the address of a N variable of type Student.

//The attributes of N are assigned to the Student class data members

Q.no.2:

//In the given program

void f(int n[]);

int main() {

int m[3]= {1, 2, 3};

f(m);

}

//The function void f(int n[]); is not defined and it does not include the proper arguments to define the factor transfer method.

//The function void f(int n[]); only gets a copy of the m[3] integer array defined in main function

Q.no.3:

#include<iostream>
using namespace std;
//function prototype
bool bigger(int a, int b, int big);

int main() {
//Factor to be compared
int big = 10;
int a,b;
cout <<"Enter the 1st integer :\n";
cin >> a;
cout <<"Enter the 2nd integer :\n";
cin >>b;
cout <<"\n";
cout << bigger( a, b, big);
return 0;
}

bool bigger(int a, int b, int big) {
  
// Function returns true or false by comparing two numbers entered by user

if (a > b) {
   if(big > a) {
   return true;
}

else {
   big = a;
   return false;
}
}
if (a < b) {
   if(big > b) {
   return true;  
}

else {
   big = b;
   return false;  
}
}
}

// 0 means False condition

// 1 means True condition

Comment down for any queries
Please give a thumbs up

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Subject- ( App Development for Web) ( language C#, software -visual studio) Exact question is-Firstly the...
Subject- ( App Development for Web) ( language C#, software -visual studio) Exact question is-Firstly the console calculator is created which perform multiply,divide,sub and add, operation and it accept all type of data (divide by 0 case as well ).Now the main motive is to create the library project from the console calculator project .Than we have to create a unit test project which test the functionality of added library.Make test like Test 1. multiply two positive number,Test 2. Add...
I'm having a warning in my visual studio 2019, Can anyone please solve this warning. Severity  ...
I'm having a warning in my visual studio 2019, Can anyone please solve this warning. Severity   Code   Description   Project   File   Line   Suppression State Warning   C6385   Reading invalid data from 'DynamicStack': the readable size is '(unsigned int)*28+4' bytes, but '56' bytes may be read.   Here is the C++ code were I'm having the warning. // Sstack.cpp #include "SStack.h" // Constructor SStack::SStack(int cap) : Capacity(cap), used(0) {    DynamicStack = new string[Capacity]; } // Copy Constructor SStack::SStack(const SStack& s) : Capacity(s.Capacity), used(s.used)...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing associated with the assignment it is failing one part of testing.   Below is the test that fails: Failed test 4: differences in output arguments: -c input data: a b c -c expected stdout: b observed stdout: a b expected stderr: observed stderr: ./test: invalid option -- 'c' Unsure where I have gone wrong. MUST BE WRITTEN IN C++ Task Level 1: Basic operation Complete...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the following subsections can all go in one big file called pointerpractice.cpp. 1.1     Basics Write a function, int square 1(int∗ p), that takes a pointer to an int and returns the square of the int that it points to. Write a function, void square 2(int∗ p), that takes a pointer to an int and replaces that int (the one pointed to by p) with its...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT