Code:
// Box.h
#ifndef BOX_H
#define BOX_H
#include <iostream>
using namespace std;
class Box : public Geometry
{
private:
double length;
double width;
double height;
const char *type;
const char name[3] = 'box';
public:
Box()
{
length = 0.0;
width = 0.0;
height = 0.0;
}
Box::Box(double l, double w, double h):Geometry(*name, *type)
{
length = l;
height = h;
width = w;
}
};
#endif
Code:
// Geometry.h
#ifndef GEOMETRY_H
#define GEOMETRY_H
#include <iostream>
#include <cstring>
using namespace std;
const int STANDARD = 51;
class Geometry
{
protected:
char *Name;
char *Type;
public:
Geometry()
{
char *Name = new char[STANDARD] = '\0';
char *Type = new char[STANDARD] = '\0';
}
Geometry(const char *n, const char *t)
{
strncpy(Name, n, STANDARD);
Name[STANDARD -1] = '\0';
strncpy(Type, t, STANDARD);
Type[STANDARD -1] = '\0';
}
/*const char *getName() const
{ return *Name; }
const char *getType() const
{ return *Type; } */
/*virtual double computeSurface() const;
virtual double computeArea() const;*/
};
#endif
Code:
// GeoMAIN.cpp
#include <iostream>
#include "Geometry.h"
#include "Box.h"
#include "Cylinder.h"
#include "Sphere.h"
using namespace std;
void main()
{
Box("Box 1", 3, 4, 3);
}
okay so im just testing it to see if it works and it is not working right now.
problem is with this:
Box::Box(double l, double w, double h):Geometry(*name, *type)
i dont know what to do though, it doesn't go over this at all in the book and my prof went over it really briefly.
Bookmarks