0

Hello there, I have to write a program using three classes. One for the input, a second for the transaction, and a third one for the report. Can I write the three class definition in one header file? Can I write the three classes in one .CPP file?
Can I find an example of a program like this on the Internet?Thanks

2
Contributors
1
Reply
2
Views
12 Years
Discussion Span
Last Post by Ejaz
0

Yes, you can write all the 3 class definations in one header file and implementation in one source file (in fact, you can write everything in one file as well).

// Class delarations
class A
{
	A();
	~A();
	void MethodOfA();
};

class B
{
	B();
	~B();
	MethodOfB();
};

class C
{
	C();
	~C();
	MethodOfC();
};

// Class Implmentations
A::A()
{
	// A ctor
}

A::~A()
{
	// A ~ctor
}

void A::MethodOfA()
{
	// MethodOfA
}

// ******************
B::B()
{
	// B ctor
}

B::~B()
{
	// B ~ctor
}

void B::MethodOfB()
{
	// MethodOfB
}

// ******************
C::C()
{
	// C ctor
}

C::~C()
{
	// C ~ctor
}

void C::MethodOfC()
{
	// MethodOfC
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.