c++中結構體定義時冒號?
struct SkBitmap::MipMap : SkNoncopyable {
int32_t fRefCnt;
int fLevelCount;
// MipLevel fLevel[fLevelCount];
// Pixels[]
static MipMap* Alloc(int levelCount, size_t pixelSize) {
if (levelCount < 0) {
return NULL;
}
Sk64 size;
size.setMul(levelCount + 1, sizeof(MipLevel));
size.add(sizeof(MipMap));
size.add(pixelSize);
if (!isPos32Bits(size)) {
return NULL;
}
MipMap* mm = (MipMap*)sk_malloc_throw(size.get32());
mm->fRefCnt = 1;
mm->fLevelCount = levelCount;
return mm;
}
const MipLevel* levels() const { return (const MipLevel*)(this + 1); }
MipLevel* levels() { return (MipLevel*)(this + 1); }
const void* pixels() const { return levels() + fLevelCount; }
void* pixels() { return levels() + fLevelCount; }
void ref() {
if (SK_MaxS32 == sk_atomic_inc(&fRefCnt)) {
sk_throw();
}
}
void unref() {
SkASSERT(fRefCnt > 0);
if (sk_atomic_dec(&fRefCnt) == 1) {
sk_free(this);
}
}
};
這個SkNoncopyable定義
class SK_API SkNoncopyable {
public:
SkNoncopyable() {}
private:
SkNoncopyable(const SkNoncopyable&);
SkNoncopyable& operator=(const SkNoncopyable&);
};
不太明白這里的冒號有什麽作用?是直接調用class SkNoncopyable 的構造函數?
[解决办法]