Objects as function arguments, C/C++ Programming

Objects as Function Arguments:

In C program there are several methods to define arguments, and in some case even a

structure can be approved as an argument.  Similarly in C++ in place of structure an object can be defined as an argument.


class interest


float i,p,n,r,a;



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

void putdata(void)

{cout<<"Interest is "<

cout<<"Amount is "<


void suminterest(interest,interest);


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


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


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


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

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


void interest::suminterest(interest i1, interest i2)


a=i1.a+i2.a;      }


int main()


interest i1,i2,i3; // Created three objects

i1.getdata(  1000,10,2); //Calculates interest and amount for object i1.


i2.getdata(10000,8,3); //Calculates interest and amount for object i2.


i3.suminterest(i1,i2); ////Total interest and amount from object i1 and i2.


return 0;


Posted Date: 9/20/2012 7:58:13 AM | Location : United States

Related Discussions:- Objects as function arguments, Assignment Help, Ask Question on Objects as function arguments, Get Answer, Expert's Help, Objects as function arguments Discussions

Write discussion on Objects as function arguments
Your posts are moderated
Related Questions
I have an assignment , can I send it

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

WAP TO ACCEPT THE BASIC SALARY OF EMPLOYEES & CALCULATE NET SALARY   #include stdio.h> #include conio.h>   void main() {                    float Basi

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Dereferencing the Pointer this Sometimes a member function requires to make a copy of the invoking instance so that it can change the copy without affecting the original instan

push and pop operation using array draw flowcharts