help to solve this error???

i write this code in visual studio 2010 and then compile it.but it shows the erroe below
"
Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
"

here is the code.please help.
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
#include <iostream>
#include <conio.h>
#include <stdlib.h>

using namespace std;

template <class T>
class stack{
public:
	stack(int = 10);//default constructor
	~stack(){delete [] stackPtr;}
	int push(const T &);
	int pop(T&);
private:
	int isEmpty() const{return topIndex==-1 ;}
	int isFull() const{return topIndex==size-1;}
	int size;
	int topIndex;
	T *stackptr;

};
//******************************
template <class T>
stack<T>::stack(int s){
	size=s>0?s:10;
	topIndex=-1;//stack is empty
	stackPtr=new T[size];
}
//**********************************
template <class T>
stack<T>::push(const T & pushValue){
	if(!isFull()){
		stackPtr[++topIndex]=pushValue;
		return 1;
	}
	return 0;
}
//********************************
template <class T>
stack<T>::pop(T& popValue){
	if(!isEmpty())
	{
		popValue=stackPtr[--topIndex];
		return 1;
	}
	return 0;
}
//*************************************
int main(){
	stack<double> doubleStack(5);
	double f=1.1;
	cout<<"pushing elemnts onto double stack"<<endl;
	while(doubleStack.push(f)){
		cout<<f<<" ";
		f+=1.1;
	}
	cout<<"\nstack is full cannot push"<<f<<"\npoping elements from double stack "<<endl;
	while(doubleStack.pop(f)){
		cout<<f<<" ";
	}
	cout<<"\nstack is empty cannot pop"<<endl;
	stack<int> intStack;
	int i=1;
	cout<<"pushing elemnts onto int stack";
	while(intStack.push(i)){
		cout<<i<<" " ;
		i+=1;
	}
	cout<<"\ncannot push "<<i<<"\npoping elements from intStack"<<endl;
	while(intStack.pop(i)){
		cout<<i<<" ";
	}
	cout<<"Stack is empty cannot pop";
	getch();
	return 0;
}
Last edited on
¿what line?
If you are going to return a Boolean value (true, false) then use bool as the return type
i think it means that the c++ doesn't your default integer
Topic archived. No new replies allowed.