Skip to content

CPP02-ex00 - My First Class in Orthodox Canonical Form #37

Description

@TheLeBerton

Files to submit

  • in ex00/ dir
  • Makefile
  • main.cpp
  • Fixed.{h, hpp}
  • Fixed.cpp

Forbidden

None

Definition of Done

  • created a class that represents a fixed-point number
    • private integer to store fixed-point number value
    • private static constant integer to store the number of fractional bits ( value will always be the integer literal 8 )
  • public default constructor ( init to 0 )
  • public copy constructor
  • public copy assignment operator overload
  • public destructor
  • public member method int getRawBits( void ) const;
  • public member method void setRawBits( int const raw );

Testing

Running this code:

#include <iostream>

int    main( void ) {
    Fixed a;
    Fixed b( a );
    Fixed c;

    c = b;
    std::cout << a.getRawBits() << std::endl;
    std::cout << b.getRawBits() << std::endl;
    std::cout << c.getRawBits() << std::endl;

    return 0;
}

Should output something similar to:

$> ./a.out
Default constructor called
Copy constructor called
Copy assignment operator called // <-- This line may be missing depending on your implementation
getRawBits member function called
Default constructor called
Copy assignment operator called
getRawBits member function called
getRawBits member function called
0
getRawBits member function called
0
getRawBits member function called
0
Destructor called
Destructor called
Destructor called
$>

Metadata

Metadata

Assignees

Labels

Type

Fields

Priority

High

Projects

Status
Working On

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions