Some code review please

Hello,

I am writing a light program which is based on a car class and a derived class which is a certain make of a car. I need to implement a OO interface for the base and derived classes. Here is what i came up with:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Definitions.
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

#ifndef __CART_H__
#define __CART_H__

enum Gear{Standard, Automatic};

class Car_t{

public:

				Car_t();			// Default CTOR. 	
				Car_t(const int _capacity);	// Capacity CTOR.
				Car_t(const Car_t& _car);	// Copy CTOR.
	virtual			~Car_t() = 0;			// DTOR.
	string			GetName()	const;		// Get the name of the car.
	Gear			GetGear()	const;		// Get the type of the car.
	int 			GetProdYear()	const;		// Get production year function.
	int 			GetCapacity()	const;		// Get capacity function.
	unsigned int 		GetID()		const;		// Get ID function.
	virtual		bool	Compare(const Car_t& _car)	const;	// Comparing between two car objects (same make model or not).
	virtual		bool	operator<(const Car_t& _car)	const;	// Is smaller operator.
	const	Car_t&		operator=(const Car_t& _car);		// Assignment operator.

private:

	const unsigned int m_ID;
	int m_capacity;
	Gear m_gear;
	const int m_prodYear;	
	string m_name;
	static unsigned int carID;		// Car ID static.
	
protected:

	void	SetName(const string& _str);		// Setting name function.
	void	SetGear(Gear _gear);			// Setting gear function.
	void	SetCapacity(int _capacity);		// Setting gear function.

};

ostream &operator<<(ostream& os, const Car_t& _car);


#endif // #ifndef __CART_H__

#ifndef __FORDT_H__
#define __FORDT_H__

class Ford_t : public Car_t{

public:

		Ford_t();	        	// Default CTOR.
		Ford_t(const int _capacity);	// Capacity CTOR.
		Ford_t(const Ford_t& _ford);	// Copy CTOR.
	virtual	~Ford_t();			// DTOR. 
	virtual		bool	operator<(const Car_t& _car)	const;	// Is smaller operator.

};

#endif // #ifndef __FORDT_H__ 

I need opinions of these interfaces please, also should i reconsider re-arranging the public/private/protected areas? another opinion needed is about the copy CTOR and the = operator, right now the derived class has no = operator as i want it to be copied the same way as the base class (the base clas is abstract), another thing is the virtuality, what do you think of the provided virtual member functions, maybe i need to change them or add something...

I'll be glad to hear any opinion... thx
Last edited on
Topic archived. No new replies allowed.