Lỗi "in function 'int main'" khi code với template

Các bạn giúp mình với ạ.nó cứ bị báo lỗi in function ‘int main’ mình nghĩ là do hàm main mình khai báo sai

#include <iostream>
#include<string.h>
#include<windows.h>
#include <vector>
using namespace std;
struct HangHoa
{
    string mahh;

};
template<typename T>

class Vector
{
public:
	// initCapacity la dung luong ban dau cua
	// vector, co gia tri ngan dinh bang 16
	Vector(int initCapacity = 16)
	{
	    int size = 0;
	    int capacity = initCapacity;
	    array = new T[capacity];
	}
	~Vector()
	{
	    delete[] array;
	}
	// rhs (right-hand side) la vector ve phai cua phep gan.
	// this la con tro toi vector hien hanh, tuc la ve trai.
	Vector & operator=(Vector & rhs)
	{
	    if (this != &rhs) // ngan can tu sao chep
		{
	        delete[] array;          // xoa mang hien tai
	        size = rhs.size;         // dat kich thuoc moi
	        capacity = rhs.capacity; // dat dung luong moi
	        array = new T[capacity]; // tao mang moi

			// Sao chep cac phan tu tu phai sang trai
	        for (int i = 0; i < size; i++)
	            array[i] = rhs.array[i];
	    }
	    return *this; // tra ve vector ve trai sau khi gan xong
	}

	// Tra ve kich thuoc vector
	int getSize()
	{
	    return size;
	}
	// Tra ve true neu vector rong, nguoc lai tra ve false
	bool isEmpty()
	{
	    return (size == 0);
	}
	// index la chi so cua phan tu can truy nhap
	T & operator[](int index)
	{
	    return array[index];
	}
	// hanghoa[]
	// newElement la phan tu moi can chen vao cuoi vector
	void pushBack(T newElement)
	{
	    // Gap doi dung luong neu vector day
	    if (size == capacity)
	        expand(2 * size);
	    // Chen phan tu moi vao ngay sau phan tu cuoi cung
	    array[size] = newElement;
	    // Tang kich thuoc
	    size++;
	}
	// pos (position) la vi tri chen.
	// newElement la phan tu moi can chen.
	void insert(int pos, T newElement)
	{
	    // Gap doi dung luong neu vector day
	    if (size == capacity)
	        expand(2 * size);
		// Dich cac phan tu sang phai de tao cho trong cho viec chen
	    for (int i = size; i > pos; i--)
	        array[i] = array[i - 1];
	    // Dat phan tu moi vao vi tri chen
	    array[pos] = newElement;
	    // Tang kich thuoc
	    size++;
	}
	// Xoa phan tu o cuoi vector
	void popBack()
	{
	    size--;
	}
	// Xoa tat ca cac phan tu
	void clear()
	{
	    size = 0;
	}
	// pos (position) vi tri cua phan tu can xoa
	void erase(int pos)
	{
	    // Dich cac phan tu sang trai de lap day cho trong de lai do viec xoa
	    for (int i = pos; i < size - 1; i++)
	        array[i] = array[i + 1];
	    // Giam kich thuoc
	    size--;
	}
	// In cac phan tu ra man hinh
	void print()
	{
		for (int i = 0; i < size; i++)
			cout << array[i] << " ";
		cout << endl;
	}
	void giaiphong()
	{
	    if(size>capacity)
        {

        }
	}
private:
	int size;
    int capacity;
    T * array;


	void expand(int newCapacity)
	{
	    if (newCapacity <= size)
	        return;
	    T * old = array;
	    array = new T[newCapacity];
	    for (int i = 0; i < size; i++)
	        array[i] = old[i];
		delete[] old;
	    capacity = newCapacity;
	}
};
void Process::(Vector &vector1)
	{
    quay_lai_menu:
    system("cls");
    while(true)
    {
    cout<<"\n\t MENU";
    cout<<"\n1.Nhap du lieu vao kho :";
    cout<<"\n2.Xuat du lieu kho: ";
    cout<<"\n3.Tim kiem hang hoa : ";
    cout<<"\n4.Them hang hoa vao kho: ";
    cout<<"\n5.Xoa hang hoa trong kho: ";
    cout<<"\n\n\t\tend";
    int luachon;
    cout<<"\nmoi nhap lua chon: ";
    cin>>luachon;
    if(luachon<1 || luachon>5)
    {
        cout<<"\nlua chon khong hop le ";
        Sleep(1000);
        goto quay_lai_menu;
    }
    else if(luachon==1)
    {
        cin.ignore();
        string new_tenmh=" ";
        cout<<"\nnhap ten hang hoa moi vao kho: ";
        getline(cin,new_tenmh);
        vector1.pushBack(new_tenmh);
        cout<<"Ban da them thanh cong!"<<endl;
        cout<<"Tu chuyen ve menu ->"<<endl;
        Sleep(1000);
        goto quay_lai_menu;
    }
    else if(luachon==2)
    {
    	cout<<"\n\t Xuat du lieu kho: ";
    	print();
        system("pause");
        cout<<"Tu chuyen ve menu ->"<<endl;
        Sleep(1000);
        goto quay_lai_menu;
    }
    else if(luachon==3)
    {
        nhap_lai_3:
        cin.ignore();
    	string c;
    	cout<<"Nhap phan hang hoa can tim kiem: ";
    	getline(cin,c);
    	 operator[](c);
    }
    else if(luachon==4)
    {
        nhap_lai_4:
        cin.ignore();
        cout<<"Chinh sua hang hoa :";
        int a;
        string mahh1=" ";
        cout<<"nhap vi tri cua hang hoa can thay the: ";
        cin>>a;
        cout<<"nhap vao ten hang hoa can thay the: ";
        getline(cin,mahh1);
        insert(a,mahh1);
        string tracuu;
        cout<<"Ban co muon tiep tuc chinh sua (y/n)? :"; cin>>tracuu;
        if (tracuu == "y" || tracuu == "Y") goto nhap_lai_4;
        cout<<"Tu chuyen ve menu ->"<<endl;
        Sleep(1000);
        goto quay_lai_menu;
        break;
    }
    else if(luachon==5)
    {
        nhap_lai_5:
        cin.ignore();
        int b;
        cout<<"Location of goods to delete:";
        cin>>b;
        erase(b);
    }
    else
    {
        break;
    }

	}
	}

int main()
{
	Vector<HangHoa> h;
	Process(h);
	return 0;
}



Cái hàm Process() nó nằm ở thư viện nào vậy bạn?

3 Likes

nó nằm ngoài mình quên mất mình sửa lại rồi nhưng nó lại báo lỗi
[Error] variable or field ‘Process’ declared void

Là một hàm? Thế :: hơi bị dư rồi đấy.

3 Likes
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?