Hey all,
I'm having a bit of trouble understanding this all...
I want to create a BinaryString class that holds a single array of characters (thus a single char*) and manages it as if it is a binary string that represents a number...
It should be able to perform operations such as:
Code:
BinaryString * a = new BinaryString(5);
BinaryString b = *a;
const BinaryString * c = new BinaryString(b);
a->getString();
delete a;
b.getString();
b.getValue();
c->getString();
c->getValue();
I'm just wondering: where do I put all these declarations in the implementation file & what are they actually meant to do?
Heres what I've got so far (no idea whether I'm even on the right track):
Code:
//BinaryString.h
#ifndef BINARYSTRING_H
#define BINARYSTRING_H
class BinaryString {
public:
BinaryString( const char * ); //constructor
BinaryString( unsigned int ); //constructor
BinaryString( const BinaryString & ); //copy constructor
~BinaryString(); //destructor
BinaryString& operator=( const BinaryString& ); //assignment
unsigned int getValue() const;
private:
const char * getString() const;
};
#endif /* BINARYSTRING_H */
Code:
//BinaryString.C
#include "BinaryString.h"
using namespace myutilities;
BinaryString::BinaryString( const char * a ) {
if(this == &a)
return *this;
delete getString();
BinaryString *a = new BinaryString(5);
return *this;
}
BinaryString::BinaryString( unsigned int b ) {
BinaryString b = *a;
}
BinaryString::~BinaryString() {
delete GetString();
}
BinaryString& BinaryString::operator=( const BinaryString& c ) {
const BinaryString *c = new BinaryString(b);
}
I'm very confused...
Can anyone help?
Thanks