Hi, i got a destructor for a class Base1.
my syntax/format is wrong. can some-one correct it for me?
Thanks,Code:Base1::virtual ~Base1() { cout << "Destroy Base" << endl; }
Hi, i got a destructor for a class Base1.
my syntax/format is wrong. can some-one correct it for me?
Thanks,Code:Base1::virtual ~Base1() { cout << "Destroy Base" << endl; }
All your qualifiers (eg: static, virtual, inline, etc) belong on the far left. Or, put another way, just as you declared it within the class with Base:: appended to the function name.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
i.e.
Code:virtual Base1::~Base1() { std::cout << "destroy all yer base" << std::endl; }
"If you tell the truth, you don't have to remember anything"
-Mark Twain
hi, did this declaration for my virtual desctructor.it continues to give me this error:virtual outside class declaration using dev c++ compiler
Code:#include <iostream> using namespace std; class Base1 { private: int baseValue; public: Base1(int y):baseValue(y){} virtual ~Base1(); }; virtual Base1::~Base1() { std::cout << "destroy all yer base" << std::endl; } int main() { }
Not quite. The virtual keyword can only be used in the class declaration, not in that type of definition. Compiling this on Comeau gives me:
Code:"ComeauTest.c", line 8: error: invalid specifier outside a class declaration virtual A::~A() ^Code:class A { int m_A; public: virtual ~A(); }; virtual A::~A() // Remove the virtual keyword here. { m_A = 5; } int main() { A a; return 0; }
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
Geez, what the hell was I thinking? I really need a vacation.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Whoops. I'll use Sebastiani's excuse.
"If you tell the truth, you don't have to remember anything"
-Mark Twain