cs Oct 2, 2014
Pointer is taking up 4 bytes ( 4 gigabyte) 2^32 addresses.
char 1 byte
int 4 bytes
double 8 bytes
pass by reference : change and return than more than 1 value.
Lab Portion in the other lab :
credit_Card.h
/*{section{Interface of Credit class}
)*/
class CreditCard
{
private:
int balance;
public :
const unsigned int limit;
CreditCard(unsigned int);
void withdraw(unsigned int){};
void deposit(unsigned int){};
int withdrawAvail(){};
int getBalance(){};
private:
bool check_invariant(){};
};
credit_Card.cpp
/*{section{Interface of Credit class}
)*/
#include "credit_card.h"
CreditCard::CreditCard(unsigned int n)
:limit(n);{
if (check_invariant() == false) throw "invariant error";
}
void withdraw(unsigned int){}
void deposit(unsigned int){}
int withdrawAvail(){}
int getBalance(){}
bool check_invariant(){
return(limt == 1000 or limit == 2000 or limit == 5000);
}
in lab3.cpp
class CreditCardTest : public TestSuite::Test
{
public:
void run
{
// test_(true); // just to check if the test cases work ok
//test_(false);
try{ CreditCard c1(500); } catch (const char *) { succeed_(); } ;
test_(c1.limit == 1000 or c1.limit == 2000 or c1.limit == 5000);
}
int main()
{
CreditCardTest t;
t.run();
t.report();
}
g++ -o lab3 lab3.cpp test.cpp credit_card.cpp

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home