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

//#include<iostream>
//using namespace std;
//
//class Stu
//{
//public:
//    int temp;
//    Stu(int t)
//    {
//        temp = t;
//    }
//    //负号
//    int operator-()            //类内重载
//    {
//        return(-temp);
//    }
//};
//////负号
////int operator-(Stu& st)        //类外重载
////{
////    return(-st.temp);
////}
////非
//int operator!(Stu& st)
//{
//    return(!st.temp);
//}
//
//int main()
//{
//    Stu st1(14);
//    cout << (-st1) << endl;
//    cout << (!st1) << endl;
//    return 0;
//}
////
////一元运算符
//// 正:+    
//// 负:-
//// 取地址:&
//// 内存操作符:*
////

 

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