#include <iostream>

using namespace std;

template<class L>
class LEST
{
	L *date;
	int first;
	int last;
public:
	LEST(int last);
	L dele();
	bool Full();
	bool Empty();
	bool Add(L value);
	bool search(L value);
	void print();
};

template<class L>
LEST<L>::LEST(int last)
{
    this->last = last>0 ? last:100;
    first-1;
    date = new L(this->last);
}

template<class L>
bool LEST<L>::Full()
{
    return first == last-1;
}

template<class L>
bool LEST<L>::Empty()
{
    return first==-1;
}

template<class L>
bool LEST<L>::search(L value)
{
    int post=0;

    for(int i=0; i<=first; i++)
    {
        if(value==date[i])
        {
            post=i;
            return true;
        }
    }
    return false;
}
template<class L>
bool LEST<L>::Add(L value)
{
    if(!Full())
    {
        if(search(value)==-1)
        {
            date[++first]=value;
        }
    }
}
the print
template<class L>
void LEST<L>::print()
{
    for(int i=0; i<=first; i++)
    {
        cout<<date[i]<<"  ";
    }
}

how make , main

Recommended Answers

All 2 Replies

From the thread title, I assume you are a Java or C# programmer. The main() in C++ works very differently from the equivalent in Java, being a bare function not associated with a class. You would write a main() function something like this:

int main()
{
    // code goes here
}

You usually would have it in a separate file from any classes you'd write, though that isn't necessary.

I know, but I really have problem with this implementation,my idea is this.

main()
{

     LEST <int>  list(int)

     list->add(4);
     list->print() 


}

but this evil, nose as I add and print

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.