제목 : 22.1. 이항 연산자 오버로드(중복) : 연산자중복.cpp
    
    
        
            
                | 
                    글번호:
                 | 
                
                 | 
                
                    169
                 | 
            
            
                | 
                    작성자:
                 | 
                
                 | 
                
                    
                        레드플러스
                        
                        
                    
                 | 
            
            
                | 
                    작성일:
                 | 
                
                 | 
                
                    
                        2005/08/21 오후 8:50:47 
                    
                 | 
            
            
            
                | 
                    조회수:
                 | 
                
                 | 
                
                    
                        5104
                    
                 | 
            
            
        
     
 
    
	
	
    
	#include <iostream.h>
class A
{
public:
    int x;
    int y;
    A operator +(A xx);
    A operator *(A xx);
};
A A::operator +(A xx)
{
    A temp;
    temp.x = x + xx.x;
    temp.y = y + xx.y;
    return temp;
}
A A::operator *(A xx)
{
    A temp;
    temp.x = x * xx.x;
    temp.y = y * xx.y;
    return temp;
}
void main()
{
    //일반 데이터 타입의 연산
    int x = 3, y = 5;
    int z = x + y;
    //사용자 정의 데이터 타입(클래스)의 연산
    A ap;
    ap.x = 50, ap.y = 100;
    A bp;
    bp.x = 50, bp.y = 50;
    A dp;
    dp.x = 2, dp.y = 3;
    A cp = ap + bp * dp;//cp.x = ap.x + bp.x, cp.y = ap.y + bp.y;
    cout << "cp.x = " << cp.x << endl;
    cout << "cp.y = " << cp.y << endl;
}