Function returning object, C/C++ Programming

Assignment Help:

Function Returning Object:

This program is like to the previous program except the function returns object.  The

main rule to be remembered is the function returning object must be defined as friend function in the class.

class interest

{float i,p,n,r,a;

public:

void getdata(int gp, int gn, int gr);

void putdata(void)

{cout<<"Interest is "<

cout<<"Amount is "<

}

Friend interest suminterest(interest,interest);

};

void interest::getdata(int gp,int gn, int gr)

{p=gp;n=gn;r=gr;

cout<<"Enter Principal: "<<"\n";

cin>>p;

cout<<"Enter Year: "<<"\n";

cin>>n;

cout<<"Enter Rate: "<<"\n";

cin>>r; i=(p*n*r)/100; a=p+i;

}

interest suminterest(interest i1, interest i2)

{interest i3; i3.i=i1.i+i2.i; i3.a=i1.a+i2.a; return i3;

}

 

int main()

{clrscr();

interest i1,i2,i3; i1.getdata(  1000,10,2); i1.putdata(); i2.getdata(10000,8,3); i2.putdata();

i3 = suminterest(i1,i2);

i3.putdata();

return 0;

}


Related Discussions:- Function returning object

Built a web crawler , To develop a web crawler such that when given a base ...

To develop a web crawler such that when given a base URL, it will traverse the entire web tree and then build an index of keywords and what URL link they appear on.   The web crawl

Padovan string, padovan string program in java // aakash , suraj , p...

padovan string program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring; public class PadovanString {     publ

Class booking system, I want source code for class booking system by using ...

I want source code for class booking system by using C++ Programming...Urgent

Evaluate the credit worthiness of a client, Write a C++ program that can be...

Write a C++ program that can be used to evaluate the credit worthiness of a client. The program reads the credit limit and the price and quantity of the item to be purchased by the

Minimum total number of shelves, At a shop of marbles, packs of marbles are...

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

Illustration of grid function, Illustration of Grid function: For illu...

Illustration of Grid function: For illustration, the script below creates two individual figure windows. At First, it clears the figure window. Then, it generates an x vector

Program to compute distance travelled by ball, Produce a pseudo code to be ...

Produce a pseudo code to be used for development compute and display some data on the bounces a ball will make when dropped from a given height. To simplify the problem, you ass

Implementation of the definition class - c++ program, Implementation of the...

Implementation of the Definition class: void Definition::put_word(char *s) {    word = new char[strlen(s)+1];    strcpy(word,s);    nmeanings = 0; }   voi

How do you connect a c++ program to c functions?, A: Using the extern "C" l...

A: Using the extern "C" linkage specification around the C function declarations. Programmers must know about mangled function names and type-safe linkages. After that they must

Program is to read the characters from keyboard, Program is to read the cha...

Program is to read the characters from keyboard: Program is to read the characters from keyboard one by one stored in different files as upper constants, lower constants, othe

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

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!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd