C++学习笔记——二元运算符

//#include<iostream>
//using namespace std;
//
//class Stu
//{
//public:
//    int a;
//    Stu(int a1)
//    {
//        a = a1;
//    }
//    //关系运算符重载
//    int operator>=(Stu& st2)    //类内定义
//    {
//        return(a >= st2.a);
//    }
//    //位运算符
//    int operator&(Stu& st2)    //类内定义
//    {
//        return(a & st2.a);
//    }
//    //逻辑运算符
//    int operator&&(Stu& st2)    //类内定义
//    {
//        return(a && st2.a);
//    }
//
//
//};
////关系运算符重载
////int operator>=(Stu& st1, Stu& st2)    //类外定义
////{
////    return(st1.a >= st2.a);
////}
////
////位运算符
////int operator&(Stu& st1, Stu& st2)    //类外定义
////{
////    return(st1.a & st2.a);
////}
//
////逻辑运算符
////int operator&&(Stu& st1, Stu& st2)    //类外定义
////{
////    return(st1.a && st2.a);
////}
//
//int main()
//{
//    Stu st1(15);
//    Stu st2(14);
//    /*cout<<(st1 >= st2)<<endl;*/
//    /*cout<<(st1 & st2)<<endl;*/
//    cout << (st1 && st2) << endl;
//
//    return 0;
//}
//
////
////算术运算符:  +,-.*./,%
////关系运算符: >=, <=, >, < , !=, ==
////位运算符:   ^  , & , I
////逻辑运算符: &&,||
////

 

posted @ 2022-12-01 16:13  努力的阿坤  阅读(78)  评论(0)    收藏  举报