게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
c++ 과제좀 도와주세요~!!!
게시물ID : programmer_13420짧은주소 복사하기
작성자 : 안녕하세
추천 : 0/4
조회수 : 538회
댓글수 : 2개
등록시간 : 2015/09/20 19:07:16
옵션
  • 본인삭제금지
void main()
{
 string a1, a2, b1, b2;
 int a3, b3, a;
 Employee Employee1(a1, a2, a3), Employee2(b1, b2, b3);
 while (1)
 {
  cout << "1. 2. 3. 4." << endl << "Select the number : ";
  cin >> a;
  switch (a)
  {
  case 1: //이름,성,월급 입력
   while (1)
   {
    cout << "Employee1 first name : ";
    getline(cin, a1);//얘가 묻힘
    cout << "Employee1 last name : ";
    getline(cin, a2);
    cout << "Employee1 salary : ";
    cin >> a3;

    cout << "Employee2 first name : ";
    getline(cin, b1);//얘가 묻힘
    cout << "Employee2 last name : ";
    getline(cin, b2);
    cout << "Employee2 salary : ";
    cin >> b3;
   }
   break;
  case 2: //연봉
   Employee1.getsalary();//실행안됨 ㅠㅠㅠㅠㅠ
   break;
  case 3: //성과급반영연봉
   break;
  }
 }
}
 
얘는 메인함수이고
 
//Employee.cpp
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
#include "Employee.h"
Employee::Employee(string a,string b,int c)
{
 setfirst_name(a);
 setlast_name(b);
 setsalary(c);
}
void Employee::setfirst_name(string a)
{
 first_name = a;
}
void Employee::getfirst_name()
{
 cout << first_name;
}
void Employee::setlast_name(string b)
{
 last_name = b;
}
void Employee::getlast_name()
{
 cout << last_name;
}
void Employee::setsalary(int c)
{
 salary = c;
 if (salary < 0)
 {
  cout << "Error : Initial salary is " << endl;
  salary = 0;
 }
}
void Employee::getsalary()
{
 cout << salary;
}
 
얘는 클래스의 내용입니다
 
퍼스트네임 입력을 하는 부분인 getline에서 묻히더라구요
 
Employee1.getsalary();//실행안됨 ㅠㅠㅠㅠㅠ
 
그리고 이줄 때문에 콘솔창 실해이 안되는거 같은데.. 이유좀 알려주세요 ㅠㅠㅠㅠ
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호