由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - inline method
相关主题
基础问题:在header里面define function最基本的C语言编程问题请教
C 里面有办法永久改变一个指针的属性吗?Why should i include .cpp instead of .h
c++头文件太tmd恶心了what's wrong with the following codes?
Help C++ Template function link error .怎样include一个函数
global variable usage question in C++template question
A weird segmentation fault!gcc 编译的时候要包括 header source file 吗?
两个class的交叉引用问题[菜鸟问问题]请问如果有两个 C++ library
#ifdef, #ifndef 这些 preprocessor 应该叫什么呀?弱问c++里有没有NULL这个keyword?
相关话题的讨论汇总
话题: pstash话题: inline话题: temp话题: storage话题: c13
进入Programming版参与讨论
1 (共1页)
n**d
发帖数: 9764
1
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.
1 (共1页)
进入Programming版参与讨论
相关主题
弱问c++里有没有NULL这个keyword?global variable usage question in C++
is there any lib can read .Z file in c++/c program?A weird segmentation fault!
C++ question about template typedef两个class的交叉引用问题
[合集] What is the inner class wrong#ifdef, #ifndef 这些 preprocessor 应该叫什么呀?
基础问题:在header里面define function最基本的C语言编程问题请教
C 里面有办法永久改变一个指针的属性吗?Why should i include .cpp instead of .h
c++头文件太tmd恶心了what's wrong with the following codes?
Help C++ Template function link error .怎样include一个函数
相关话题的讨论汇总
话题: pstash话题: inline话题: temp话题: storage话题: c13