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();
Are comments included during compilation stage and placed in EXE file as well? - No, comments encountered by compiler are disregarded. - Their only purpose is ease and guida
Observe that our model of evaluation allows for combinations whose operators are compound expressions. (a) Use this observation to describe the behavior of the following procedu
Define a function in c program: int f1() { static int x=10; return x; } int f2() { int y=5; return y; } extern int z; void f() {
#include stdio.h struct complex { float real; float imag; }; struct complex complexadd(struct complex,struct complex); void main() { Date: 26
Within C we access external devices by means of a pointer i.e. address. The address could point to any memory mapped device i.e. Ram, Rom, Duart, Disk drives etc. Therefore there i
Problem : Change to palindrome A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your ta
how to write c code to solve assignment problem?
Specifying a Class: As discussed a class is defined to develop an algorithm and bind it together in a core shell. A class is an abstract data type (ADT). The binding of dat
How many levels deep can include files be nested? - As such, there is no limit to number of levels of nested include files you can have however your compiler might run out of s
electricity biil code
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