what is the wrong in this function ?

so ?
and how can i call it in main ?

please help

the error is under the code ^_^


1
2
3
4
5
6
7
8
9
10
11
12
 template<class T1>
queue1<T1>::queue1(T1 a[],int b,int c,int d)

{
	array_of_queue1=new a[b];
	for(int i=0;i<size;i++)
		{
			array_of_queue1[i]=a[i];
		}
	first=c=0;
	last=d=0;
}



1
2
3
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>C:\Users\Odai\documents\visual studio 2010\Projects\last HW\Debug\last HW.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
From error it looks tike you don't have main function anywhere
no i have it !! what about my code is there any mistake in it ?

and how can i call it in main ?
array_of_queue1 = new a[b]; Makes no sense.
1
2
first=c=0;
last=d=0;
Useless. Why you even bother with sending variables if you will make it =0 anyway?

and how can i call it in main
It is a member function. Constructor to be precise. Why do you wrote it that way if you don't know how to use it?

I want to say it again: Error you got tells that there isn't main() function anywhere. There is several possible reasons:
* cpp file where main() is is not included in project build list.
* Showing great deal of standard compliance (sarcasm mode off) MSVC is waiting for function named differently from main() ( possibly _tmain(), check your compiler settings )
Last edited on
ok i know what do you mean mmm

now my code is like

1
2
3
4
5
private:
	T1*array_of_queue1[10];
	int size;
	int first;
	int last;


queue1();//constructor

1
2
3
4
5
6
7
8
template<class T1>
queue1<T1>::queue1()

{
	size=10;
	first=0;
	last=0;
}





in main

1
2
queue1<int> v;
	v.ADD(2);



but the compiler still give the same error !!
so is it like what do you say " Showing great deal of standard compliance (sarcasm mode off) MSVC is waiting for function named differently from main() ( possibly _tmain(), check your compiler settings )" ?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef QUEUE_1_H
#define QUEUE_1_H
#include<iostream>
using namespace std;
template<class T1>
class queue_1
{
private:
	T1*array_of_queue1[10];
	int size;
	int first;
	int last;

public:
	queue_1();//constructor
	~queue_1();//distructor
	queue_1(queue_1&);//copy constructor
	queue_1& operator(queue_1&);// assignment operator
	void ADD(T1);// function to add value
	void deletequeue1();//function to delete value


};
#endif
template<class T1>
queue_1<T1>::queue_1()

{
	size=10;
	first=0;
	last=0;
}
template<class T1>
	queue_1<T1>::~queue_1()
	{
		delete[] array_of_queue1;
		array_of_queue1=0;
	}
	template<class T1>
	queue_1<T1>::queue_1(queue_1& a)
	{
		array_of_queue1=new T1[a.size];
		for(int i=0;i<size;i++)
		{
			array_of_queue1[i]=a.array_of_queue1[i];
		}
	}
	template<class T1>
	queue_1& queue_1<T1>::operator(queue_1&)
	{
		if(size!=a.size)
		{
			size=a.size;
			delete[]array_of_queue1;
			array_of_queue1=new T1[size];
		}
		for(int i=0;i<size;i++)
		{
			array_of_queue1[i]=a.array_of_queue1[i];
		}
		return*this;
	}
	template<class T1>
	void queue_1<T1>::ADD(T1 a)
	{
		if(last=size)
		{
			cout<<"the array is full you cant add more value ";
		}
		else 
			array_of_queue1[last]=a;
		last++;
	}
	template<class T1>
	void queue_1<T1>::deletequeue1()
	{
		if(first=last)
		{
			cout<<"sorry the array is empty you can't remove any thing";
		}
		else
			return(array_of_queue1[last--]);
	}

There is no #endif at the end of your header.
queue_1& queue_1<T1>::operator(queue_1&)
operator what?

And I still think that cpp file where your main function is is not in compile list. Because if this was compiled it were compile-time errors, not linking ones.
there is #endif in line 24!

mmm really i dont know what is wrong !
That means you could include several template definitions...

Create new project. Copy all your old code in it. Try to compile.
yes i will do that plz wait me ^_^
my program working but there's wrong in this function !!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
template<class T1>
	queueone<T1> queueone1<T1>::operator=(queueone& a)
	{
		if(size!=a.size)
		{
			size=a.size;
			delete[]array_of_queue1;
			array_of_queue1=new T1[size];
		}
		for(int i=0;i<size;i++)
		{
			array_of_queue1[i]=a.array_of_queue1[i];
		}
		return *this;
	}



1
2
3
4
1>c:\users\odai\documents\visual studio 2010\projects\hw5\hw5\queueone.h(54): error C2143: syntax error : missing ';' before '<'
1>c:\users\odai\documents\visual studio 2010\projects\hw5\hw5\queueone.h(54): error C2988: unrecognizable template declaration/definition
1>c:\users\odai\documents\visual studio 2010\projects\hw5\hw5\queueone.h(54): error C2059: syntax error : '<'
1>c:\users\odai\documents\visual studio 2010\projects\hw5\hw5\queueone.h(54): error C2039: '=' : is not a member of '`global namespace'' 
Topic archived. No new replies allowed.