试图通过编译我的程序 g++ -o prog1 main.cpp -std=c++0x
我收到错误:
/tmp/cc1pZ8OM.o: In function `main':
main.cpp:(.text+0x148): undefined reference to `Hash::insert(int, char)'
collect2: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
main.cpp中
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <functional>
#include "Hash.h"
using namespace std;
int main(int argc, char *argv[]) {
//preset prime number
int prime = 101;
hash<char> h1;
int key;
Hash HashTable;
// check for Request & string parameters
if(argc != 3) {
cout << "Run program with 2 parameters. [Lower …Run Code Online (Sandbox Code Playgroud) 只是想知道,因为我正在与C++项目的合作伙伴合作,是否有可能显式删除已在堆栈上初始化的对象?(所以没有指针)
例如:
MinHeap h(data); // on stack
Run Code Online (Sandbox Code Playgroud)
VS
MinHeap *h = new MinHeap();
Run Code Online (Sandbox Code Playgroud)
从来没有出现过,因为我总是在堆上为大对象分配内存.