当前位置: 首页>>代码示例>>C++>>正文


C++ StringStack::push方法代码示例

本文整理汇总了C++中StringStack::push方法的典型用法代码示例。如果您正苦于以下问题:C++ StringStack::push方法的具体用法?C++ StringStack::push怎么用?C++ StringStack::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringStack的用法示例。


在下文中一共展示了StringStack::push方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

int
main(void)
{
	StringStack	stack;

	//用初始化构造函数构造一个字符串常量数组
	MyString	my[] = {
		MyString("hello"), 
		MyString("programmer"), 
		MyString("It`s a nice day"), 
		MyString("keep do it"), 
		MyString("Never give up") 
	};

	//字符串常量指针入栈,注意存的是指针,所以采用取地址操作
	for (int i = 0; i < sizeof my / sizeof *my; i++) {
		stack.push(&my[i]);
	}

	//返回的是一个常量对象指正,故只有常量成员函数才能调用
	const MyString* cm;
	for (int i = 0; i < sizeof my / sizeof *my; i++) {
		//注意此处cm是指针,直接进行赋值即可不需要进行取地址操作
		cm = stack.pop();
		cm->print();
	}

	return 0;
}
开发者ID:forzenheart,项目名称:Thinking-In-C-resource,代码行数:29,代码来源:c0820.cpp

示例2: main

int main() {
  StringStack ss;
  for(int i = 0; i < iCsz; i++)
    ss.push(&iceCream[i]);
  const string* cp;
  while((cp = ss.pop()) != 0)
    cout << *cp << endl;
} ///:~
开发者ID:archfp,项目名称:floorplan,代码行数:8,代码来源:StringStack.cpp

示例3: main

int main() {
  StringStack ss;
  for (int i = 0; i < iCsz; i++)
    ss.push(&iceCream[i]);

  const MyString *cp;
  while((cp = ss.pop()) != NULL)
	  cp->print();
}
开发者ID:taras-ko,项目名称:br-eckel,代码行数:9,代码来源:StringStack.cpp

示例4: main

/** Test-driving code for StringStacks.
 */
int main() {
   StringStack* testStack = new StringStack();
   cout << "Pushing \"AAA\" ... ";        //no "endl", keep next on same line
   testStack->push("AAA"); 
   cout << "Pushing \"BBB\" ... " << endl;
   testStack->push("BBB"); 
   cout << "Size is now " << testStack->size() << endl;
   testStack->pop();
   cout << "Pop---size is now " << testStack->size() << endl;
   string c = testStack->pop();
   cout << "I popped the string \""
        << c << "\", size now " << testStack->size() << endl;
   cout << "Can I pop again?" << endl;
   string d = testStack->pop();
   cout << "Oops!  I got: \"" << d << "\"" << endl;
   //delete(testStack);
   StringStack test2 = (*testStack);
   return (0);
}
开发者ID:Oswamano,项目名称:SchoolProjects,代码行数:21,代码来源:StringClient.cpp

示例5: main

int main() {
	StringStack ss;
	for (int i = 0; i < iCsz; i++)
		ss.push(new MyString(&iceCream[i]));
	const MyString* cp;
	
	while ((cp = ss.pop()) != 0) {
		cp->print();
		delete cp;
	}
} ///:~
开发者ID:aadarshasubedi,项目名称:B.Eckel-Thinking-in-CPP-vol.1,代码行数:11,代码来源:Ex20.cpp

示例6: main

int main() {
    StringStack ss;
    myString* ms;
    for(int i = 0; i < iCsz; i++){
	ms = new myString(iceCream[i]);
	ss.push(ms);
    }
    const myString* cp;
    while((cp = ss.pop()) != 0)
	cout << cp->str << endl;
}
开发者ID:chenxuehu2016,项目名称:thinking-in-cpp,代码行数:11,代码来源:ex20.cpp

示例7: main

int main(int argc, char const *argv[])
{
	StringStack SS;
	for (int i = 0; i < ICsz; ++i)
	{
		SS.push(iceCream[i]);
	}
	const char* cp;
	while((cp = SS.pop()) != 0)
		cout << cp << endl;
	return 0;
}
开发者ID:songshuangkk,项目名称:Arch,代码行数:12,代码来源:enum2.cpp

示例8: main

int main() {
  ifstream in("InheritStack.cpp");
  assure(in, "InheritStack.cpp");
  string line;
  StringStack textlines;
  while(getline(in, line))
    textlines.push(new string(line));
  string* s;
  while((s = textlines.pop()) != 0) { // No cast!
    cout << *s << endl;
    delete s;
  }
} ///:~
开发者ID:archfp,项目名称:floorplan,代码行数:13,代码来源:InheritStack.cpp

示例9: DoDirs

bool CommandLineInterface::DoDirs()
{

    StringStack tempStack;
    
    std::string cwd;
    if (!GetCurrentWorkingDirectory(cwd))
    {
        return false;
    }
    
    // cwd is top of stack
    if (m_RawOutput)
    {
        m_Result << cwd;
    }
    else
    {
        AppendArgTagFast(sml_Names::kParamDirectory, sml_Names::kTypeString, cwd);
    }
    
    // print rest of stack making a new one
    while (m_DirectoryStack.size())
    {
        if (m_RawOutput)
        {
            m_Result << ' ' << m_DirectoryStack.top();
        }
        else
        {
            AppendArgTagFast(sml_Names::kParamDirectory, sml_Names::kTypeString, m_DirectoryStack.top());
        }
        
        tempStack.push(m_DirectoryStack.top());
        m_DirectoryStack.pop();
    }
    
    // put the old stack back together
    while (tempStack.size())
    {
        m_DirectoryStack.push(tempStack.top());
        tempStack.pop();
    }
    return true;
}
开发者ID:SoarGroup,项目名称:Soar,代码行数:45,代码来源:cli_file_system_cmds.cpp


注:本文中的StringStack::push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。