Saturday 28 December 2013

C++ Program having functions setmarks inside which 3 subject marks should be set & Make total a friend function inside which all 3 subject marks total will be done

#include<iostream.h>
  class Marks
{
  int a;
  int b;
  int c;
  public:
  void setmarks()
  {
  cout<<"Enter Marks Of Subject ";
  cin>>a>>b>>c;
  }
friend int total(Marks m);
};
int total(Marks m)
{
  return(m.a+m.b+m.c);
}
Void main()
{
  Marks x;
  x.setmarks();
  cout<<total(x);
}

No comments:

Post a Comment