Hi everybody!
I'm working on a following program:

#include "stdafx.h"
#include <iostream>
using namespace std;
class char_queue 
{
protected:
	struct charList
	{
	public:
		char val;
		charList* next;
		charList(char ch, charList* ptr)
		{
			val = ch; next = ptr;
		}
	};
protected:
	charList* begin;
	charList* end;
	void clearCharList();
public:
	char_queue();
	bool find(char ch);
	virtual void add(char ch);
	virtual void clear()=0;
	virtual void print();
};
char_queue::char_queue()
{
	begin = end = NULL;
}
void char_queue::clearCharList()
{
	while(begin!=NULL)
	{
		char_queue::charList* current = begin->next;
		delete begin;
		begin=current;
	}
}
bool char_queue::find(char ch)
{
	char_queue::charList* current = begin;
	while(current!=NULL)
	{
		if(current->val==ch) return true;
		current = current->next;
	}
	return false;
}
void char_queue::add(char ch)
{
	char_queue::charList* current = new char_queue::charList(ch, NULL);
	if(begin == NULL) begin = end = current;
	end->next = current;
	end = current;
}
void char_queue::print()
{
	char_queue::charList* current = begin;
	while(current!=end)
	{
		cout<<current->val<<"  ";
		current=current->next;
	}
	cout<<current->val<<endl;
}
int main(int argc, char*argv[])
{
	char_queue ob;
	char myChar[5]={'H','e','l','l','o'};
	for (int i=0; i<5; i++)
		ob.add(myChar[i]);
	ob.print();
	system("PAUSE");
	return 0;
}

While compiling I got an error here: char_queue ob;
The error is: Error 1 error C2259: 'char_queue' : cannot instantiate abstract class
I don't understand what is going on?
So I really need your helps.
Thanks in advanced!

virtual void clear()=0; makes your class abstract (as it is a pure virtual function). You must inherit from your class to use it.

BTW, you don't have to specify "public" as an access specifier in a struct, line 9, as structs have a default public access to all members (and classes have a default private).

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.