Hi.
This compiles under MSVC 7.0 and the free MSVC 7.1
Also compiler under gcc 2.96
works on Comeau non-strict
Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:non-strict warnings C++
compiler error strict
Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:strict errors C++
"ComeauTest.c", line 8: error: omission of "class" is nonstandard
friend T;
^
1 error detected in the compilation of "ComeauTest.c".
If I use friend typename T in strict mode
Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:strict errors C++
"ComeauTest.c", line 8: error: a class or namespace qualified name is
required
friend typename T;
^
"ComeauTest.c", line 13: error: "MakeFinal<T>::MakeFinal() [with T=Final]"
is
inaccessible
Final() {std::cout << "Final Hello World" << std::endl;};
^
"ComeauTest.c", line 13: error: "MakeFinal<T>::~MakeFinal() [with T=Final]"
is
inaccessible
Final() {std::cout << "Final Hello World" << std::endl;};
^
"ComeauTest.c", line 14: error: "MakeFinal<T>::~MakeFinal() [with T=Final]"
is
inaccessible
~Final() {std::cout << "Final Goodbye World" << std::endl;};
^
4 errors detected in the compilation of "ComeauTest.c".
Below is the code I used#include <iostream>
template<typename T>
class MakeFinal
{
private:
MakeFinal() {std::cout << "MakeFinal Hello World" << std::endl;};
~MakeFinal() {std::cout << "MakeFinal Goodbye World" << std::endl;};
friend T;
};
class Final : virtual public MakeFinal<Final>
{
public:
Final() {std::cout << "Final Hello World" << std::endl;};
~Final() {std::cout << "Final Goodbye World" << std::endl;};
};
/*
class Derived : public Final
{
public:
Derived() {std::cout << "Derived Hello World" << std::endl;};
~Derived() {std::cout << "Derived Goodbye World" << std::endl;};
};
*/
int main()
{
Final f;
// Derived *d = new Derived();
// delete d;
return 1;
}