Results 1 to 21 of 21

Thread: Need help with creating Binary Class

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    4

    Need help with creating Binary Class

    I am trying to create a class to manipulate binary number including +, -, & * functions. here is what i already have.

    Code:
    #include <iomanip.h>
    #include <stdio.h>
    #include <iostream.h>
    #include <stdlib.h>
    
    class bin_num{
       char data[8];
       int todec(bin_num x);
       bin_num tobin(int x);
       bin_num operator +(bum_num x);
       bin_num operator -(bum_num x);
       bin_num operator *(bum_num x);}
    
    bin_num::int todec(bin_num x){
       int y;
       y = strtol(x, NULL, 2);
       return y;
    }
    
    bin_num::bin_num tobin(int x){
       char bnum[8];
       itoa(x, bnum, 2); 
       return bnum;
    }
    
    bin_num::bin_num operator +(bum_num x){
    }
    
    bin_num::bin_num operator -(bum_num x){
    }
    
    bin_num::bin_num operator *(bum_num x){
    }
    i don't quite know what the operator functions should be. If anyone could help, PLEASE!!!!
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width