visual c++ - Who can help me understand this C++ programming project? -


as have been learning week, overloading standard operators on class, can exploit intuition of users of class. overloading operator, changing way compiler uses operator based on arguments.

here project week:

create c++ program using visual studio design “phonecall” class holds phone number call placed, length of call in minutes, , rate charged per minute. overload extraction , insertion operators class. in program, overload == operator compare 2 phonecalls. consider 1 phonecall equal if both calls placed same number. also, create main() function allows enter ten phonecalls array. if phonecall has been placed number, not allow second phonecall same number. save file phonecall.cpp.

compile application using visual studio , run make sure error free.

the following code have far:

#include <iostream>  #include <string>   using namespace std;   class phonecall {  private:      string phonenumber;      double perminuterate;      double calldurationminutes;  public:      bool operator==( const phonecall &n ) const;      friend ostream & operator<<( ostream &f, const phonecall &n );      friend istream & operator>>( istream &f, phonecall &n );   };   bool phonecall::operator==( const phonecall &n ) const {      return phonenumber == n.phonenumber;   };   ostream & operator<<( ostream &f, const phonecall &n ) {      f << "phone number: " << n.phonenumber <<           ", duration: " << n.calldurationminutes <<           " minutes, rate: " << n.perminuterate << endl;   return f;   }   istream & operator>>( istream &f, phonecall &n ) {   f >> n.phonenumber;   f >> n.calldurationminutes;   f >> n.perminuterate;   return f;   }   int main( ) {   phonecall a[10];   cout << "enter 10 phone numbers, duration in minutes, , per-minute rates." <<       endl << "separate each space , hit enter complete it." << endl;   ( int i= 0; < 10; ) {       cin >> a[i];       int j;       ( j= 0; j < i; ++j )           if ( a[i] == a[j] ) {               cout << "duplicate number information ignored. try again." << endl;               break;           }       if ( j == ) ++i;   }   ( int i= 0; < 10; ++i )       cout << a[i];   system("pause");  return 0;   }  

you have many, many syntax errors in program.

where infile declared?

infile = new streamreader("name.txt", true); 

you have brace instead of bracket on line:

infile = new streamreader{"name.txt"); 

you bitwise or-equaling string value on line:

while ((invalue = infile.readline()) |= null) 

did mean !=?


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -