error C3662: override specifier 'new' only allowed on member functions of managed classes

Posted by William on Stack Overflow See other posts from Stack Overflow or by William
Published on 2010-05-16T07:22:36Z Indexed on 2010/05/16 7:30 UTC
Read the original article Hit count: 307

Filed under:
|
|
|
|

Okay, so I'm trying to override a function in a parent class, and getting some errors. here's a test case

#include <iostream>
using namespace std; 

class A{
public:
    int aba;
    void printAba();
};

class B: public A{
    public:
    void printAba() new;
};

void A::printAba(){
    cout << "aba1" << endl;
}

void B::printAba() new{
    cout << "aba2" << endl;
}

int main(){
    A a = B();

    a.printAba();

    return 0;
}

And here's the errors I'm getting:

Error   1   error C3662: 'B::printAba' : override specifier 'new' only allowed on member functions of managed classes   c:\users\test\test\test.cpp 12  test
Error   2   error C2723: 'B::printAba' : 'new' storage-class specifier illegal on function definition   c:\users\test\test\test.cpp 19  test

How the heck do I do this?

© Stack Overflow or respective owner

Related posts about c++

Related posts about parent-child