I'm trying to write a program with a has-a relationship but the initialization isn't working. The error I'm getting is:

h:\oop labs\license retry\license2.0\license2.0\licenses.cpp(15) : error C2275: 'Date' : illegal use of this type as an expression

Licenses::Licenses(int id, string name, string ad, Date, Date)
:issue_date(Date), expiry_date(Date) // error occurs here
{
	set_id(id);
	set_name(name);
	set_addy(ad);
	c_count++;
	cout << "Constructor called " << c_count << " times";
}

This has something to do with it also

class Date
{
	int day, month, year;
	static int c_date, d_date;

public:
	Date();
	Date(int, int, int);
	Date(Date &);
	~Date();
	void set_dd(int);
	void set_mm(int);
	void set_yy(int);
	const int get_dd();
	const int get_mm();
	const int get_yy();
	const void display();
};

Recommended Answers

All 2 Replies

When writing in-line functions you can not leave out the variable names. What you have on line 2 is a data type -- Date is a class, not the name of an object. Code it something like this:

Licenses::Licenses(int id, string name, string ad, Date dt1, Date dt2)
:issue_date(dt1), expiry_date(dt2) // error occurs here
{

Ok, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.