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();
please answer the question of following Write a function that calculates the number of elapsed days between two dates. For example the days between Feb 3, 1970 and June 21, 1980? B
C Program to check FACTORIAL main() { int i,j,m,fact,sum=0; clrscr(); printf("ENTER THE NO.: "); scanf("%d",&m);
C program to Print Fibonacci series upto n using recursion: int fibo(long int); void main() { long int a=0,n; printf ("how many term
Q: however shouldn't I always use a printOn() method instead of a friend function? A: No. The usual cause people wish to always use a printOn() method instead of a friend fu
Define Static Storage Class in C Programming? The Static declarations have distinct and important uses. This allows the local variable to keep its previous value when the block
a) Define an Asset base class that provides the following method: class Asset { public: virtual double getValue()=0; }; This will be the base class for both stock an
Scrape a site and save as csv Project Description: I want a programmer to create scraping software. I'll want every page scraped of name, job title, company, and url. There a
I. COURSE DESCRIPTION Develops a working knowledge of object-oriented concepts in areas of classes, inheritance, data structures, error handling, templates and file processing.
Flash my terminal vx670 Project Description: Have VeriFone software need it to communicate with the vx670 through com port 1 it is not talking I'm not sure why have all the r
What are the debugging methods you employ while came across a problem? A: Debugging with tools such as: 1. DBG, GDB ,Forte, Visual Studio. 2. Using tusc to trace
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