This is a program..to implement stack operations..it is working fine..but
a warning message is being displayed..as " Functions containing for are not
expanded inline". I would be glad if anyone can tell me the reason for this.
Thanks for all the support.

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>

#define max 5

class stack
{
	protected:
		int st[max];
		int top;
	public:
		stack()
		{
			top = -1;
		}
		void push()
		{
			int item;
			cout<<"Enter the item to push :";
			cin>>item;
			top++;
			st[top] = item;
		}

		int pop()
		{
			int item;
			item = st[top];
			top--;
			return(item);
		}

		void display()
		{
			cout<<"\n The stack contains \n "<<endl;
			for(int i = top;i>=0;i--) // here
				cout<<st[i]<<endl;
		}
};

class stack_cond : public stack
{
	public:
		void push()
		{
			if(top == max-1)
				cout<<"\n Stack Overflow "<<endl;
			else
			{
				stack :: push();
				if(top==max-1)
					cout<<endl<<"After push stack is full "<<endl;
			}
		}
		int pop()
		{
			int item;
			if(top == -1)
			{
				cout<<endl<<"Stack underflow"<<endl;
				return NULL;
			}
			else
			{
				item = stack :: pop();
				if(top == -1)
					cout<<endl<<"After pop stack is empty"<<endl;
					return(item);
			}
		}

		void display()
		{
			if(top == -1)
				cout<<"Stack is empty "<<endl;
			else
				stack :: display();
		}
};

void main()
{

	stack_cond s;
	int choice;
	cout<<"Program For Stack Using Inheritance \n";
	do
	{
		clrscr();
		cout<<"1. Push \n";
		cout<<"2. Pop  \n";
		cout<<"3. Display \n";
		cout<<"4. Exit \n";

		cout<<"Enter your choice:";
		cin>>choice;

		switch(choice)
		{
			case 1:	s.push();
				s.display();
				break;

			case 2:	//s.display();
				choice = s.pop();
				if(choice!=0)
					cout<<endl<<"The item "<<choice
					<<" is poped from the top of the stack"<<endl;
				break;

			case 3:	s.display();
				break;

			case 4:	exit(0);
		}

		cout<<"Press any key to continue.."<<endl;
		getch();

	}
	while(choice!=4);
}

Hi,
if u dont want that error message , define the display() (in class stack ) function outside the class. Actually all the function defined within the class are considered as inline function automatically. inline function is just a recommendation to the compiler. compiler may ignore this recommendation. now any function which contains a for loop or some complex code can't be expanded in a line. thats why the compiler is giving the warning. u just define the same function outside the class. check it out...

thnnx a lottttt dude,..
it worked
seems am still lackin wid basics

hi..................
you've mentioned above that the warning of c++.it create when you use or write the program of class and use key words like for,do,while etc.

means u can't use for and other loop in class definition................

Hi " functions containing for are not expanded inline" I'm using structure in called function I'm getting that warnings plsss help me

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.