PlayXP

새로운 사이트를 준비하는 동안
여러분의 이야기가 이어질 작은 공간을 마련했습니다.

PlayXP 서비스를 준비하며 함께 작업하고 있는 운영진 일러스트

군필여고생 행님들 불쌍한 자게이 코딩을 도와주세요

조회 수 1,0731



은행 프로그램을 만들라는데

 

목표가 계좌생성, 조회, 삭제입니다.

 

관리자 계정+ 조회하면 이름이나 계좌번호순으로 선택해서 정렬하고 봅니다.

 

연결리스트라는 녀석을 쓰면 참 이쁘겠다 싶어서 저녁 8시부터 지금까지 도전해보고있는데

 

아까 오류도 포함해서 문법오류 다해결했다! 하면 프로그램이 정지되버립니다

 

ㅁㄴㅇㄹ 어디가 문제라서 프로그램이 터지는건가요?

 

 

 

추가ㅣ

문제가 되는 코드

#pragma once

using namespace std;

class Account {

std::string Name = "Default";

std::string Number = "Default";

int Password = 0;

int Money = 0;

public:

static int count;

Account();

~Account();

// 계좌 관 리  

void setAccount(); // 설정 

void delAccount(); // 삭제 

void showData();   // 표시 

void showDataTitle();

// 입력 

void getString(std::string &line);

void getInt(int& line);

void operator= (Account &ref){;

Name = ref.Name;

Number = ref.Number;

Password = ref.Password;

Money = ref.Money;

}

// 계좌 덮어씌우기 

void overload (Account &ref){

Name = ref.Name;

Number = ref.Number;

Password = ref.Password;

Money = ref.Money;

}

// 계좌번호 중복 확인 

bool check (Account ref){

if (this->Number == ref.Number) return true;

else return false;

}

};

 

void Account::showDataTitle(){

std::cout << "Name" << "\t" << "Number" << "\t" << "Money" <<"\tPassword" << std::endl;

}

 

void Account::showData(){

std::cout << Name << "\t" << Number << "\t" << Money << "\t" << Password << std::endl;

}

void Account::setAccount(){

std::cout << "이 름 : ";

getString(Name);

std::cout << "계좌번호 : ";

getString(Number);

std::cout << "비밀번호 : ";

getInt(Password);

std::cout << "잔 액 : ";

getInt(Money);

 

}

void Account::delAccount(){

}

void Account::getString(std::string &line){

getline(std::cin, line);

fflush(stdin);

}

void Account::getInt(int& line){

std::cin >> line;

fflush(stdin);

}

 

Account::Account(){

Money = 0;

}

Account::~Account(){

}​ 

 

 

-------------------

main.cpp

 

 

class List{

class Link{

public:

Account Acc;

Link * Node = NULL;

};

Link * Head;

public:

List();

int ListCount;

// function

void addAcc(Account &input); // 연결리스트 추가 

void showList(); 

};

 

List::List(){

List* Head = NULL;

this->ListCount = 0;

}

 

void List::addAcc(Account &input){

Link* newLink = new Link;

newLink->Acc = input;

newLink->Node = NULL;

Link* temp = Head;

if ( Head == NULL ){

Head = newLink;

ListCount++;

return;

}

else{

while(temp){

if(input.check(temp->Acc)){

std::cout << "중복된 계좌번호" << std::endl;

return;

}

temp = temp->Node;

}

}

temp->Node = newLink;

ListCount++;

}

 

void List::showList(){

//Link* temp = Head;

//temp->Acc.showData();

Head->Acc.showData();

}

 

int main(int argc, char** argv) {

List A;

Account input;

input.setAccount();

A.addAcc(input);

std::cout << A.ListCount << std::endl;

A.showList();

return 0;

}​ 

목록으로

댓글

댓글을 불러오는 중...