Answer to Question #216144 in C++ for KASHIF UR REHMAN

Question #216144
create a class same as int bultin data type which will initialize its member data from zero or from some other value. the variable of this class work with unary operator with prefix or postfix astrics
1
Expert's answer
2021-07-11T14:43:29-0400
#include <iostream>

using namespace std;
class  Integer
{
    private:
          int first;
    public:
         Integer(){
    first = 0;
         
}
        Integer(int f){
        first = f;
}
int getPrefix_(){
return --first;
}
int getPostfix_(){
    return first--; 
    
}
int getPostfixplus(){
return first++;

}
int getPrefixplus(){
   return +first;
}
};
int main()
{ 
    Integer t(10);
    
    cout<<t.getPostfixplus()<<endl;
    
cout<<t.getPrefixplus()<<endl;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS