I have 3 files like this. the compiler does not allow ~PStash has "inline"
flag.
temp_inline.h
class PStash {
void** storage;
public:
PStash() : storage(0) {}
~PStash();
};
temp_inline.cpp
#include "temp_inline.h"
inline PStash::~PStash() {
delete []storage;
}
temp_inlinemain.cpp
#include "temp_inline.h"
int main() {
PStash intStash;
}
It is fine if all the code in one file. What is wrong?
j********r 发帖数: 21
2
all inline functions should be in header files.
n**d 发帖数: 9764
3
Why does this one work?
C13_PStashmain.cpp
#include "C13_PStash.h"
int main() {
PStash intStash;
intStash.inflate(3);
}
C13_PStash.h
#ifndef PSTASH_H
#define PSTASH_H
class PStash {
void** storage;
public:
PStash() : storage(0) {}
~PStash();
void inflate(int increase);
int add(void* element);
};
#endif
C13_PStash.cpp
#include "C13_PStash.h"
#include
using namespace std;
PStash::~PStash() {
delete []storage;
}
inline void PStash::inflate(int increa
【在 j********r 的大作中提到】 : all inline functions should be in header files.