M
Mark K
Im just getting back into C++ after a long hiatus. Ive been coding in
Java for the last 3 years and Im finding it hard to get back into the
swing of things since C++ went standard. Anyhow,,,here's my question
given the following class def and implementation, how should I be
cleaning up my variables?
Also, when implementing the "has a" relationship with other classes
and regular datatypes, when should pointers or just references be
used?
As you can see, I lost most of my C++ knowledge to Java's
over-simplified impl.
Thanks for any clarification
Mark
/*in Customer.h*/
#ifndef COMMON_CUSTOMER_H
#define COMMON_CUSTOMER_H
#include <string>
class Customer
{
public:
Customer();
virtual ~Customer();
const string getName() const ;
void setName( const string & ) ;
private:
string name ;
};
#endif
/* in Customer.cxx */
#include <string>
#include "Customer.h"
Customer::Customer()
{
name = "";
}
Customer::~Customer()
{
//delete name ; <- I know this isn't right, but how do I release this
}
//Or should I be returning a pointer to this reference?
const string Customer::getName() const
{
return this->name ;
}
void Customer::setName( const string &newName)
{
name = newName ;
}
Java for the last 3 years and Im finding it hard to get back into the
swing of things since C++ went standard. Anyhow,,,here's my question
given the following class def and implementation, how should I be
cleaning up my variables?
Also, when implementing the "has a" relationship with other classes
and regular datatypes, when should pointers or just references be
used?
As you can see, I lost most of my C++ knowledge to Java's
over-simplified impl.
Thanks for any clarification
Mark
/*in Customer.h*/
#ifndef COMMON_CUSTOMER_H
#define COMMON_CUSTOMER_H
#include <string>
class Customer
{
public:
Customer();
virtual ~Customer();
const string getName() const ;
void setName( const string & ) ;
private:
string name ;
};
#endif
/* in Customer.cxx */
#include <string>
#include "Customer.h"
Customer::Customer()
{
name = "";
}
Customer::~Customer()
{
//delete name ; <- I know this isn't right, but how do I release this
}
//Or should I be returning a pointer to this reference?
const string Customer::getName() const
{
return this->name ;
}
void Customer::setName( const string &newName)
{
name = newName ;
}