Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
Dynamic Initialization of objects:
It is initializing the objects by passing the valued to the constructor from the user input or
other means. Through cin operator a value can be stored in a variable and passed through a constructor this form of initializing an object is known dynamic initialization.
Dynamic Constructor:
The memory allocation for a constructor can be managed using new operator called new,
similarly the memory can be free with another operator called deleter.
class dynmem
{ char *name;
int length;
public:
dynmem(void)
{length =0;
name = new char[length+1];
}
dynmem(char *s)
{length = strlen(s);
name = new char[length+1];//for null terminator
strcpy(name,s);
void display(void)
{cout< } void join(dynmem &a, dynmem &b); }; void dynmem::join(dynmem &a, dynmem &b) {length = a.length+b.length; delete name; name = new char[length+1]; strcpy(name,a.name); strcat(name,b.name); }; void main() { clrscr(); char *first="Electronic "; dynmem name1(first); dynmem name2("and Communication "); dynmem name3("Engineering"); dynmem s1,s2; s1.join(name1,name2); s2.join(s1,name3); name1.display(); name2.display(); name3.display(); s1.display(); s2.display(); }
void join(dynmem &a, dynmem &b);
};
void dynmem::join(dynmem &a, dynmem &b)
{length = a.length+b.length;
delete name;
name = new char[length+1]; strcpy(name,a.name); strcat(name,b.name);
void main()
{
clrscr();
char *first="Electronic ";
dynmem name1(first);
dynmem name2("and Communication ");
dynmem name3("Engineering"); dynmem s1,s2; s1.join(name1,name2); s2.join(s1,name3); name1.display();
name2.display(); name3.display(); s1.display(); s2.display();
3 . Write a ‘C’ program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number.
how to fill the blank spaces in the board of 4*4 matrix with the minimum of 4 colors and the condition is the adjacent element should not have the same colour
Create a program WordCount1Main.java doing the following: For each word in the le word.txt { Create an object of the class Word { Add the object to a set of the type java.uti
Program is to store all ASCII char into a file: void main() { ofstream fout("ascii.txt"); int i,n=256; for(i=1;i { fout }
Access privileges 1. If the designer of the base class needs no one, not even a derived class to access a member, then that member should be made private. 2. If the designer
Hello. I need a solution for this assignment. It is for C++ Language: Create a BusinessPartner class that contains a first name, company name, and a telephone number. Create a Con
Write a program of constructors and destructors Make a class drugs having encapsulated data for medicine name, whether solid or liquid, price and purpose of use. From this clas
How to write a function template A function template should be written at the beginning of the program in the global area, or you may place it into a header file. All function
Friend for Overloading Operators Sometimes friend functions cannot be avoided. For example with the operator overloading. Consider the following class that have data members to
In POS system, cashier computer connect to printer using serial rs232 usb or cable. We need to capture data from that connection, and parsing the data to get total amount for every
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +91-977-207-8620
Phone: +91-977-207-8620
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd