Показать сообщение отдельно
Старый 18.03.2008, 10:04   #1
Неактивный пользователь
 
Пол:Мужской
Регистрация: 18.03.2008
Сообщений: 6
Репутация: 0
По умолчанию помогите пожалуста c программой на с++(сдавать срочно)

только начинаю осваивать Visual C++, написал часть программы - не знаю как доделать

Проект нужно сдавать через пару дней а я не знаю как завершить прогу, помогите кто может
Заранее большое спасибо!!!!


Задание:


-The class is called “Worker”.

-It has 3 private members: name (char type), age (integer type), salary(double type).

-It has two constructors:

one has no arguments and it initializes name with 'C', age with 20, and salary with 100.00;
the other takes two arguments (char char1, int var_age) and it initializes name with char1’s value, age with var_age’s value,

and salary with 200.00.

-The class also has a member function access which outputs name’s value, age’s value, and salary’s value to screen.

-The class has a friend function overloading operator == so that it will return true when comparing two objects of the same

class Worker. For example, if wk1 and wk2 are two objects of class Worker and their 3 private members are same, (wk1= =wk2)

will return true.

-Write a main program to test your class implementation.

Код:
 

//Worker.cpp

#include "Worker.h"
#include <iostream>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;
  
Worker:Worker(char char1, int var_age)
// determine if two Worker are equal and return true, otherwise return false

   bool Worker::operator ==( const Worker &right,const Worker &left) const
   {
      if ((right.getChar != left.getChar) && (right.getAge != left.getAge))
         return false; 
	  else      
	     return true; 
   } // end function operator==


Код:
//Header file

#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <iostream>

#ifndef Worker_H
#define Worker_H

class Worker //time 
{
public:
   Worker( char = 'C'; age = 20; salary = 100.00 ); // constructor
   Worker(char char1, int var_age); //constructor
   worker=char1;
   age=var_age;
   salary=200.00;         
private:
   char worker;
   int age;
   double salary;

friend bool operator==(const Worker &)const;

     // inequality operator; returns opposite of == operator     
     bool operator!=( const Worker &right,const Worker &left) const                 
     {                                                           
        return ! ((*this == right)&&(*this == left); // invokes Worker::operator==
     } // end function operator!=                                

}; // end class Time

#endif


Код:
// prj33.cpp 
#include "stdafx.h"
#include "Worker.h"
using std::cout;
using std::cin;
using std::endl;

int main()
{
	Worker cc1('A',13)
	
	
	
	return 0;
}
XXXAlex вне форума
 
Ответить с цитированием Вверх
 
Время генерации страницы 0.02040 секунды с 10 запросами