我在使用我的c ++源文件或者编译器本身时遇到了一些奇怪的事情.似乎当我尝试编译文件时,它会给我发一条消息 -
未定义的引用"Basic_int_stack :: Basic_int_stack()
未定义的引用"Basic_int_stack :: Push(int)
这是我的代码(我还是初学者,所以不要指望任何疯狂的专业代码)
头文件:
class Basic_int_stack
{
public:
// This part should be implementation independent.
Basic_int_stack(); // constructor
void push( int item );
int pop();
int top();
int size();
bool empty();
private:
// This part is implementation-dependant.
static const int capacity = 10 ; // the array size
int A[capacity] ; // the array.
int top_index ; // this will index the top of the stack in the array
};
Run Code Online (Sandbox Code Playgroud)
实现:
#include "basic_int_stack.h"// …Run Code Online (Sandbox Code Playgroud) 我对c ++很新,我想知道为什么我的cin.get()没有停止cmd中的程序在完成时立即关闭?我在我之前的代码上尝试了cin.get()并且它工作正常,但由于某种原因它不适用于此代码.
#include <iostream>
int main()
{
using namespace std;
int carrots;
cout << "How many carrots do you have?" << endl;
cin >> carrots;
cout << "You have " << carrots << endl;
cin.get();
return 0;
}
Run Code Online (Sandbox Code Playgroud)