디시인사이드 갤러리

갤러리 이슈박스, 최근방문 갤러리

갤러리 본문 영역

C++ 공부중이 뉴비가 질문드려요..ㅜㅜ

cpp뉴비(183.101) 2012.12.06 01:49:37
조회 106 추천 0 댓글 6

Account  객체를 만들고,
그거를 관리하는 AccountHandler를 만들었는데요.


동적할당으로 account를 계속 추가할 수 있는데요.
1번을 눌러서 account 하나 할당을 하고,
그다음에 4번 버튼을 눌러서 그 값을 확인하고 싶은데,
자꾸 값을 가져오지를 못하는데 조금만 도움을 주시면 감사하겠습니다.ㅜㅜ


#include <iostream>
#include "stdlib.h"
#include "string.h"
#include "stdio.h"
#include <conio.h>

using namespace std;

class Account{

public :
 int getAccountNumber();
 char* getAccountName();
 int getAccountMoney();
 void setAccountNumber(int acNumber);
 void setAccountName(char* acName);
 void setAccountMoney(int acMoney);
 
private :
 int accountNumber;
 char* accountName;
 int accountMoney;

};

class AccountHandler{

public :
 AccountHandler(int acNum);
 void showMenu(void) const;
 void makeAccount(void);
 void depositMoney(void);
 void withdrawMoney(void);
 void showAllAccInfo(void) ;
 Account* getAcArray(void);
 ~AccountHandler();

private :
 Account *acArray[100];
 int acNum;

};


int main(){

 int menuSelectNumber;
 
 AccountHandler accountHandler(0);
 
 while(1){

  accountHandler.showMenu();
  cin >> menuSelectNumber;
  
  switch(menuSelectNumber){
  
  case 1:
   accountHandler.makeAccount();
   break;
  case 2:
   accountHandler.depositMoney();
   break;
  case 3:
   accountHandler.withdrawMoney();
   break;
  case 4:
   accountHandler.showAllAccInfo();
   break;
  case 5:
   exit(1);
  default :
   break;
  } //end switch

 } // end while

} // end main


//---------------------------------------------------------------
int Account :: getAccountNumber(){
 return accountNumber;
}

char* Account :: getAccountName(){
 return accountName;
}

int Account :: getAccountMoney(){
 return accountMoney;
}

void Account :: setAccountNumber(int acNumber){
 accountNumber = acNumber;
}

void Account :: setAccountName(char *arr){
 accountName = arr;
}

void Account :: setAccountMoney(int acMoney){
 accountMoney = acMoney;
}
//---------------------------------------------------------------

//---------------------------------------------------------------

AccountHandler :: AccountHandler(int initAcNum){
 acNum = initAcNum;
}

void AccountHandler :: showMenu(void) const {
 cout << "------- MENU -------" << endl;
 cout << "1. 계좌개설" << endl;
 cout << "2. 입 금" << endl;
 cout << "3. 출 금" << endl;
 cout << "4. 계좌정보 전체 출력"<< endl;
 cout << "5. 프로그램 종료"<< endl;
 cout << "선택 : "; 
}

void AccountHandler :: makeAccount(void) {
 
 int tempInt;
 
 Account* tempAccount = new Account;
 acArray[++acNum] = tempAccount;

 //cout << ":::::::::::::::::::::::0:::" << acNum << endl;
 //cout << ":::::::::::::::::::::::0:::" << acArray << endl;
 //cout << ":::::::::::::::::::::::0:::" << tempAccount << endl;
 //cout << ":::::::::::::::::::::::::::" <<endl;

 cout <<"[계좌개설]" << endl;
 cout << "계좌 ID : ";
 cin >> tempInt;
 tempAccount->setAccountNumber(tempInt);
 cout <<"이름 :  ";

 tempInt = 0;
 char name[100];
 cin >> name;

 while(name[tempInt] != '\0'){
  tempInt ++;
 }

 char* arr = new char[tempInt];
 arr = name;
 tempAccount->setAccountName(arr);

 cout << "입금액 : ";
 cin >> tempInt;
 tempAccount->setAccountMoney(tempInt);
 cout << "계좌개설완료" << endl;

 //cout << ":::::::::::::::::::::::1:::" << acNum << endl;
 //cout << ":::::::::::::::::::::::1:::" << acArray << endl;
 //cout << ":::::::::::::::::::::::1:::" << tempAccount << endl;
 //cout << ":::::::::::::::::::::::::::" <<endl;

 delete tempAccount;

}

void AccountHandler :: depositMoney(void) {
 cout <<"[입 금]" << endl;
 cout <<"계좌ID:115" << endl;
 cout <<"임급액:70" << endl;
 cout <<"입금완료" << endl;
}

void AccountHandler :: withdrawMoney(void) {
 cout <<"[출 금]" << endl;
 cout <<"계좌ID:115" << endl;
 cout <<"임급액:70" << endl;
 cout <<"입금완료" << endl;
}

void AccountHandler :: showAllAccInfo(void)  {
 cout <<"[전체출력]" << endl;
 cout << ":::::::::::::::::::::::2:::" << acNum << endl;
 cout << ":::::::::::::::::::::::2:::" << acArray << endl;
 cout << ":::::::::::::::::::::::::::" <<endl;
 Account * tempAA  = new Account;
 tempAA = (Account*) acArray;

 int tempNumber = tempAA[0].getAccountNumber();
 cout << tempNumber;

 //cout << ":::::::::::::::::::::::3:::" << (Account*) getAcArray() << endl;
 //cout << ":::::::::::::::::::::::3:::" << acArray << endl;
 //cout << ":::::::::::::::::::::::3:::" << tempAA << endl;
 //cout << ":::::::::::::::::::::::::::" <<endl;

 //int moneymoney = tempAA[0].getAccountMoney();
 
 //Account* TEMPAA = acArray;

 //TEMPAA->getAccountMoney();
 //cout << ":::::::::::::::::::::::" << acArray[0]->getAccountMoney() << endl;
 //Account* tempAccountA = new Account[acNum];
 //tempAccountA = getAcArray();
 
 //for(int j = 0; j < acNum; j++){
 // cout << tempAccountA[j].getAccountMoney();
 //}
 
}

Account* AccountHandler :: getAcArray(void){
 return *acArray;
}

AccountHandler :: ~AccountHandler(){
 
}

//---------------------------------------------------------------

//---------------------------------------------------------------

추천 비추천

0

고정닉 0

0

댓글 영역

전체 댓글 0
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 반응이 재밌어서 자꾸만 놀리고 싶은 리액션 좋은 스타는? 운영자 25/07/28 - -
AD 휴대폰 액세서리 세일 중임! 운영자 25/07/28 - -
341466 뒺일것같다 내일도 출근한다 ??(14.63) 12.12.24 41 0
341465 ap장비랑 공유기의 차이가 뭐임? [3] ㅂㅈㄷ(125.137) 12.12.24 117 0
341464 지금 자료구조 공부하고 있는데 잘하고 있는거냐? [1] 엣헴(14.44) 12.12.24 152 0
341463 스프링 프레임 워크 고수봐라 [2] ㅁㄴㅇ(59.11) 12.12.24 123 0
341462 액티브x 문제점 [2] ㅁㄴㅇ(59.11) 12.12.24 121 0
341461 윈도우의 Process ID 말인데 [3] ㅁㄴㄻㄹ갤로그로 이동합니다. 12.12.24 117 0
341460 컴퓨터 공부하다보면 참 신기한거 많어 [3] ㅇㅇ(58.102) 12.12.24 259 0
341459 사장님, 크릐스마스 보너스는 없나여??? qㅈㄷ(14.32) 12.12.24 56 0
341458 발바리 뜯자 발바리 나는 한국인 발바리 냠냠 Kyle(220.244) 12.12.24 54 0
341456 액티브 x 인가한 공무원새끼는 누굴까 ? [1] ㅁㄴㅇ(59.11) 12.12.24 121 0
341454 으르릉으르릉.. .멍멍!! 왈왈!! 캬악... 캬악!!... 머엄ㅇ!! [3] Kyle(220.244) 12.12.24 117 0
341453 ㅋㅋ 니들 float과 double 의 차이는 알고 갤질하냐 [7] 11(210.179) 12.12.24 423 0
341452 과거엔 여자들이 정치했다는 게 트루? [3] 최모군(211.44) 12.12.24 179 0
341451 게임만드는거 소원이었는데 이룰수있겠다 [2] appllee갤로그로 이동합니다. 12.12.24 160 0
341449 스프링 프레임 워크 책 뭐가 좋음? 피자 쏜다 [4] ㅇㄴㅁㅇㄴㅁ(59.11) 12.12.24 206 0
341447 우리 회사가 징검다리 휴무때 안쉬는 이유 [3] ㅇㅇ(58.102) 12.12.24 121 0
341446 우리회사만 빼고 다 징검다리휴무냐? [2] 얼룩돼지갤로그로 이동합니다. 12.12.24 89 0
341445 꾸준히 하는 것도 중요한데 뭘 하느냐가 중요한듯 [2] ㅇㅇ(58.102) 12.12.24 99 0
341444 내년에 구글이 낸다는 구글 x폰 왠지 구글 글라스일것 같지 않냐? [1] ㅇㅇ(58.102) 12.12.24 86 0
341443 형들 프로그래머 사이트 좀 알려주세요.. [4] 형들질문좀..(168.126) 12.12.24 226 0
341441 mysql 질문 int 형 튜플 하나를 튜플--하고 싶어요 [1] 펔끄유갤로그로 이동합니다. 12.12.24 55 0
341438 CString 길이 어디까지 늘어남요? [2] 펔끄유갤로그로 이동합니다. 12.12.24 89 0
341435 곧 졸업하는 두 친구 소식을 들었는데 일광면(175.215) 12.12.24 119 0
341434 개나소나 취직이구나 [2] 일광면(175.215) 12.12.24 267 0
341432 십년전 듣던노래 씨디 crc 복원해서 듣는데 새롭다 잉잉잉갤로그로 이동합니다. 12.12.24 82 0
341431 시간이 지나도 [6] (110.15) 12.12.24 121 0
341430 한 20시간 후가 되면 [1] (1.214) 12.12.24 88 0
341429 현직자 형들 질문 컴퓨터+수학, 컴퓨터+전자 어떤 조합이 좋을까요? [5] 복수전공(59.0) 12.12.24 245 0
341427 인터넷에 돌아다니는 소스들은 가라가 80%인거같아 [2] 펔끄유갤로그로 이동합니다. 12.12.24 196 0
341426 그냥 회의감이 들어서 그런데.. [3] dd(115.23) 12.12.24 171 0
341425 이클립스에서 로그캣 탭 클릭하면 다운 먹는데 ...왜 그런지 아시는분?ㅠ 길가던놈갤로그로 이동합니다. 12.12.24 33 0
341424 FTP PASSIVE 모드 왜발생하는거야? ㅇㅇ(114.71) 12.12.24 27 0
341423 추상클래스질문이요 형들 ㅎㅎ [1] ASDASD(211.178) 12.12.24 70 0
341422 형들 마우스에서 들어오는 정보나 USB포트에서 들어오는 정보 [1] ㅇㅇ(175.212) 12.12.24 56 0
341421 횽들 VS 깔려있는 상태에서도 디버그 런타임이 날아갈 수 있어? 아나(118.217) 12.12.23 27 0
341419 웹 프로젝트 진행중인데... [3] 하앍뿌갤로그로 이동합니다. 12.12.23 179 0
341418 게임메이커 : 스튜디오가 세일중입니다! [1] wnsrn3436(211.200) 12.12.23 392 0
341417 자바에서 서버 응답이 올때까지 코드를 실행하지 않으려면 어떻게 해야 함? [28] ㄹㅇㄴㅁ(115.20) 12.12.23 331 0
341416 여기 라즈베리 파이 쓰는 횽 있음? ㅠㅠ ㅇㅇㅇ(121.144) 12.12.23 98 0
341415 자바,jsp,js 물어보삼. (초보임). 그래도물어봐 아는거알려줄께 [5] 초보자바(61.102) 12.12.23 198 0
341414 GTA4 1.0.7.0 멀티하자 ㅇㅁㄴㅇㄴ(124.216) 12.12.23 64 0
341413 나랑 똑같이 생기고 목소리 같은 사람을 쥬카카부라 라고 하던가? [7] Kyle(220.244) 12.12.23 233 0
341409 마인크래프트 ceo 이야기를 담은 다큐맨터리 [4] 고랭?갤로그로 이동합니다. 12.12.23 294 1
341408 떡볶이먹고싶다 정수정•‿•갤로그로 이동합니다. 12.12.23 64 1
341406 크리스마스때 뭐할예정이냐 [6] ㅁㅁ(114.204) 12.12.23 197 0
341405 도움! 힝아(115.161) 12.12.23 52 0
341403 fatal error LNK1104: 'msvcprtd.lib' [1] aaaa(14.53) 12.12.23 106 0
341400 루트 트레이스에서 ISP의 내부장비가 찍힘? dot(124.197) 12.12.23 76 0
341399 우리 5년더 하게됬다고 ! [2] ㅁㅁ(114.204) 12.12.23 304 0
341398 컴공전공자들이 글케 대우가 똥망이라던데 [3] ㅣㄱ(1.241) 12.12.23 353 0
뉴스 어센트(ASC2NT), 신곡 'DON'T MOVE' 첫 주 활동 성료! 강렬 임팩트 디시트렌드 07.30
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2