Visual Studio Notes Stacks

From Minor Miracle Software
Jump to: navigation, search

Visual Studio Notes Stacks[1]

The Stack can take classes without any special features.

#include <SDKDDKVer.h> 
#include <afxcoll.h>
#include <stack>
#include <atlstr.h>

class StackItem
{
public:
    // Note: classname and method must be constant C-style strings.
  CString classname;
  CString methodname;
};
	stack <StackItem> s1;
	StackItem one;
	one.classname = CString("class1");
	one.methodname = CString("method1");

   s1.push( one );

   stack <int>::size_type i;
   i = s1.size( );
   cout << "The stack length is " << i << "." << endl;

   StackItem two = s1.top( );
  printf("The element at the top of the stack is %S \n", two.classname);


Internal Links

Parent Article: Visual Studio Notes