Get premium membership and access questions with answers, video lessons as well as revision papers.
Yes, data from class is also copied when an object of a derived class is assigned to another object of the same derived class.Here is a program that demonstrates this fact:
#include
using namespace std;
class base {
int a;
public:
void load_a(int n) {a = n ; }
int get_a() {return a;}
};
class de: public base {
int b;
public:
void load_b(int n) {b=n;}
int get_b() {return b;}
};
int main ()
{
derived ob1, ob2;
ob1.load_a(5);
ob1.lo);
// assign ob1 to ob2
ob2 =ob1;
cout << "Here is ob1's a and b: " ;
cout <cout << "Here is ob2's a and b:";
cout << ob2.get_a() << ' ' << ob2.get_b () << "\n";
/*As you can probably guess, the output is the same for each object.*/
return 0;
}
Githiari answered the question on May 29, 2018 at 17:40
- Using the stack class, write a function called loadstack() that returns a stack that is already loaded with letters of the alphabet (a-z.). Assign this...(Solved)
Using the stack class, write a function called loadstack() that returns a stack that is already loaded with letters of the alphabet (a-z.). Assign this stack to another object in the calling routine and prove that it contains the alphabet. Be sure to change the stack size so it is large enough to hold the alphabet.
Date posted: May 29, 2018. Answers (1)
- Explain five good programming practices(Solved)
Explain five good programming practices.
Date posted: May 29, 2018. Answers (1)
- List five examples of softwares(Solved)
This is a question based on Introduction to Computer Systems unit in Computer science course
Date posted: May 26, 2018. Answers (1)
- List three categories of operating systems(Solved)
List three categories of operating systems.
Date posted: May 26, 2018. Answers (1)
- As a programmer, what is the significance of the Integrated Development Environment(IDE) in programming?(Solved)
As a programmer, what is the significance of the Integrated Development Environment(IDE) in programming?
Date posted: May 26, 2018. Answers (1)
- As a programmer, briefly explain why comments are used when writing a program(Solved)
As a programmer, briefly explain why comments are used when writing a program.
Date posted: May 26, 2018. Answers (1)
- Define the following terms as used in computer programming: (a.) A compiler (b.) A debugger (c.) An algorithm(Solved)
Define the following terms as used in computer programming: (a.) A compiler (b.) A debugger (c.) An algorithm
Date posted: May 26, 2018. Answers (1)
- What is computer programming?(Solved)
What is computer programming?
Date posted: May 26, 2018. Answers (1)
- Using an example, differentiate a code from a program(Solved)
Using an example, differentiate a code from a program.
Date posted: May 26, 2018. Answers (1)
- Explain three techniques of detecting deadlocks in a computer system(Solved)
Explain three techniques of detecting deadlocks in a computer system.
Date posted: May 16, 2018. Answers (1)
- Explain common types of computer networks(Solved)
Explain common types of computer networks.
Date posted: May 16, 2018. Answers (1)
- What is social Engineering?(Solved)
What is social Engineering?
Date posted: May 16, 2018. Answers (1)
- Explain characteristics of information security within an organization? (Solved)
Explain characteristics of information security within an organization?
Date posted: May 16, 2018. Answers (1)
- Giving examples explain threats to data security(Solved)
Giving examples explain threats to data security.
Date posted: May 16, 2018. Answers (1)
- What is a cyber crime?(Solved)
What is a cyber crime?
Date posted: May 16, 2018. Answers (1)
- Describe the difference between an internal and an external hyperlink(Solved)
Describe the difference between an internal and an external hyperlink
Date posted: May 14, 2018. Answers (1)
- What’s the difference between encoding, encryption, and hashing?
(Solved)
What’s the difference between encoding, encryption, and hashing?
Date posted: May 13, 2018. Answers (1)
- Expand on Claude Shannon’s theorem. Differentiate the term confusion and diffusion as envisaged by Shannon to strengthen crypto-algorithm.(Solved)
Expand on Claude Shannon’s theorem. Differentiate the term confusion and diffusion as envisaged by Shannon to strengthen crypto-algorithm.
Date posted: May 13, 2018. Answers (1)
- In DES, the encryption and decryption algorithms are the same. Is that also the case in AES?(Solved)
In DES, the encryption and decryption algorithms are the same. Is that also the case in AES?
Date posted: May 13, 2018. Answers (1)
- What do we mean by public-key cryptography?(Solved)
What do we mean by public-key cryptography?
Date posted: May 13, 2018. Answers (1)