Thank you,Ankur.Yes,char * is OK.
I think the program below can make us more clearly of how VC6.0 works.
class AA
{
public:
AA() : v(0)
{
++count;
cout << "Default constructor" << endl;
}
AA(int d) : v(d)
{
++count;
cout << "constructor" << endl;
}
~AA()
{
--count;
}
void Show()
{
cout << "v=" << v << "\tcount=" << count << endl;
}
private:
int v;
static int count;
};
int AA::count = 0;
AA a(5);
extern AA a; // A new object a is generated
int main()
{
{
AA b(4);
b.Show(); // Now three objects have been generated.
}
a.Show();
}
// The result
constructor
Default constructor
constructor
v=4 count=3
v=0 count=2
Press any key to continue
So we can see clearly that VC6 generated a new object when running to
the code of "extern string str" and the former object was covered.
niuwei
|