After I read the reference link: Must provide destructor in the PIMPL, I do the follow the example, but the g++(4.6.1) doesn't generate compile error as I expected
The source code is:
// Predeclare.h
#include <vector>
#include <boost/scoped_ptr.hpp>
#include <iostream>
struct A;
class Predeclare
{
std::vector<A> alist_;
boost::scoped_ptr<A> pa_;
//A a;
public:
Predeclare();
//~Predeclare();
void print();
void set(int i);
};
// Predeclare.cpp
#include "Predeclare.h"
struct A
{
int a;
};
Predeclare::Predeclare(): pa_(new A)
{}
/*
Predeclare::~Predeclare()
{}
*/
void Predeclare::print()
{
std::cout << pa_->a << '\n';
}
void Predeclare::set(int i)
{
pa_->a = i;
}
int main()
{
Predeclare c1;
c1.set(10);
c1.print();
return 0;
}
Then, compile the program
g++ Predeclare.cpp
Everything is ok, Why the g++(4.6.1) doesn't generate compile error?