派生クラスの関数が、基底クラスの仮想関数をオーバーライドしていることを示す。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// override_keyword.cpp | |
// CplusplusPractice | |
// | |
// Created by masai on 2015/05/22. | |
// Copyright (c) 2015年 masai. All rights reserved. | |
// | |
#include <iostream> | |
using namespace std; | |
struct A{ | |
public: | |
virtual void function() = 0; | |
}; | |
struct B : A{ | |
public: | |
void function() override { | |
cout << "override" << endl; | |
} | |
}; | |
int main(int argc, char* argv[]){ | |
B obj; | |
obj.function(); | |
} |
0 件のコメント:
コメントを投稿