본문 바로가기

C++

c ++ 수업중 정리 다 못한부분


//#include<iostream>

// int main(void)
// {
//
//  std::cout<< "Hello World!!"<<std::endl;
//  std::cout<< "Hello "<<"World!!" <<std::endl;
//  std::cout<<1<<'a'<<"String" << std::endl;
//  return 0;
//
// }
/*
//------------------------------------------------------------
int main()
{

 int val1, val2;
 std::cout<<" 첫번째 숫자 입력:";
 std::cin>>val1;

 std::cout<<"두번째 숫자 입력: ";
 std::cin>>val2;

 int result=val1+val2;
 std::cout<<"덧셈 결과:"<<result<<std::endl;
 return 0;
}*/
//----------------------------------------------------------
/*
#include<iostream>

void funtion()
{
 std::cout<<"funtion() call"<<std::endl;

}
void funtion(char c)
{

 std::cout<<"funtion(char c) call"<<std::endl;
}
void funtion(int a,int b)
{
 std::cout<<"funtion(int a, int b) call"<<std::endl;
}

int main(){
 funtion();
 funtion('a');
 funtion(12,13);

 return 0;

}
*/

//----------------------------------------------------------------------
/*
#include<iostream>

int BoxVolume( int length, int width=1, int height=1 );

int main()
{
 std::cout<<"[3,3,3]  :"<<BoxVolume(3,3,3)<<std::endl;
 std::cout<<"[5,5,def] :"<<BoxVolume(5,5)<<std::endl;
 std::cout<<"[7,def,def] :"<<BoxVolume(7)<<std::endl;
 return 0;
 
}
int BoxVolume(int length, int width, int height)
{
 return length*width*height;
}
*/

/*44오류
#include<iostream>

namespace A_COM
{

void function()
 { 
  std::cout<<"A.com에서 정의한 함수"<<std::endl;
 }
}

namespace B_COM

 {
  void function()
  { 
   std::cout<<"B.com에서 정의한 함수"<<std::endl;
  }
 }

int main()
{
 A_COM::function(); 
 B_COM::function();
 return 0;
}
*/


/* p55
using namespace::std;
const int NAME_LEN=20;

typedef struct _Account
{

 int id; // 계좌번호
 int balance;   //잔액
 char name[NAME_LEN];//고객이름

}Account;
Account pArray[100];
int index=0;

void PrintMenu();  //메뉴출력
void MakeAccount();  //계좌개설
void Deposite();  //입금
void Withdraw();  // 출금
void Inquire();   //잔액조회

enum(MAKE=1, DEPOSIT, Withdraw, Inquire, exit);

int main()
{

 int choice;
 while(1);
 {

  PrintMenu();
  cout<<"선택:";
  cin>>choice;
 
 switch(choice)
 {
 case MAKE:
  MakeAccount();
  break;

 case DEPOSIT:
 Deposite();
  break;
 case WITHDRAW:
  Withdraw();
  break;
 
 case INQUIRE:
  Inquire();
 case EXIT:
  return 0;
 default :
  cout<<"Illegal selection.."<<endl;
  break;
  }
 }
 return 0;
}


void PrintMenu()
 {
  cout<<"-----------Menu----------"<<endl;
  cout<<"1. 계좌 개설"<<endl;
  cout<<"2.입금"<<endl;
  cout<<"3. 출금"<<endl;
  cout<<"4.잔액조회"<<endl;
  cout<<"5.프로그램 종료"<<endl;

 }
void MakeAccount()
{

 int id;
 char name[NAME_LEN];
 int balance;

 cout<<"계좌개설-------<endl;
 cout<<"계좌 ID:"; cin>>id;
 cout<<"이 름:"; cin>>name;
 cout<<"입금액:"; cin>>balance;

 pArray[index],id=id;
 pArray[index].balance=balance;
 strcpy{pArray[index].name, name)'
  index++;
 }

 void Deposit()
 {
  int money;
  int id;
  cout<<"계좌id "; cin>>id;
  cout<<"입금액: ";
  for(int i=0; i<index; i++)
  {
   if(pa

}
*/

'C++' 카테고리의 다른 글

c++ 상속하는 클래스의 객체 생성 및 소멸과정  (0) 2010.01.19
C++ 생성자  (0) 2010.01.18
c++/c 언어 메모리의 동적 할당  (0) 2010.01.13
c++ 메모리의 동적할당 Debug_new.cpp p88  (0) 2010.01.13
call by value  (0) 2010.01.13