You have to declare the over-ridden functions as part of your class definition
class Circle : public Shape { public: Circle(int); virtual void area(); // overrides Shape::area void perimeter(); // overrides Shape::perimeter virtual void volume(); private: int r; };
Note that the use of virtual
here is optional.
As n.m. noted, you should also include a virtual destructor in Shape
. You may also want to make its virtual functions pure virtual (based on your comment about Shape
being abstract)
class Shape { public: virtual ~Shape() {} virtual void area() = 0; virtual void perimeter() = 0; virtual void volume() = 0; };
Related Posts:
- Inheriting constructors
- Inheriting constructors
- cannot declare variable ‘’ to be of abstract type ‘’
- How to call a parent class function from derived class function?
- QltAW.png
- What is object slicing?
- Class template inheritance C++
- Struct inheritance in C++
- C++ calling base class constructors
- Here is some error with my .h file which show [Error] unterminated #ifndef when I include my class template in it
- How to implement 2D vector array?
- What is the difference between g++ and gcc?
- What is the best way to use a HashMap in C++?
- What is the difference between float and double?
- How do I find the length of an array?
- C++ — expected primary-expression before ‘ ‘
- Using getline() with file input in C++
- g++ ld: symbol(s) not found for architecture x86_64
- Making my own toString() method on c++ struct
- Struct Constructor in C++?
- What is meant with “const” at end of function declaration? [duplicate]
- Read file line by line using ifstream in C++
- Virtual/pure virtual explained
- error: redefinition of class
- Officially, what is typename for?
- How do I iterate over the words of a string?
- C++ Vector of pointers
- error: lvalue required as unary & operand
- What is use of c_str function In c++
- Is there a decent wait function in C++?
- What does T&& (double ampersand) mean in C++11?
- C++ – No matching member function for call to ‘push_back’
- How to find memory leak in a C++ code/project?
- invalid use of non-static member function
- Cannot open include file: ‘stdio.h’ – Visual Studio Community 2017 – C++ Error
- srand(time(0)) and random number generation
- How to convert integer to double implicitly?
- How do I tokenize a string in C++?
- Reverse Contents in Array
- Why would we call cin.clear() and cin.ignore() after reading input?
- Should I learn C before learning C++?
- Comparison with string literal results in unspecified behaviour?
- c++: No instance of overloaded function
- C++ error: Undefined symbols for architecture x86_64
- Visual Studio debugger error: Unable to start program Specified file cannot be found
- Printing the correct number of decimal points with cout
- Destructor for a linked List
- Why use a new call with a C++ ‘vector’?
- Identifier is undefined
- What are the most widely used C++ vector/matrix math/linear algebra libraries, and their cost and benefit tradeoffs?
- Insert object at index of vector c++
- Read whole ASCII file into C++ std::string
- Reading getline from cin into a stringstream (C++)
- How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)?
- C++ int float casting
- Best way to extract a subvector from a vector?
- How do malloc() and free() work?
- Call to implicitly deleted copy constructor in LLVM
- C++ Linked List Node with class
- What is the use of intptr_t?
- std::wstring VS std::string
- Base class undefined
- C++ – Assigning null to a std::string
- The program can’t start because libgcc_s_dw2-1.dll is missing
- C++ – Too Many Initializers for Arrays
- Reading string by char till end of line C/C++
- getline: identifier not found
- Colorizing text in the console with C++
- Show two digits after decimal point in c++
- Reference to non-static member function must be called
- Call to non-static member function without an object argument compiler error
- How can I assign an array from an initializer list?
- I get this error: “glibc detected”
- How can I get and use the header file
in my C++ program? - GCC -fPIC option
- initialize a vector to zeros C++/C++11
- “vector” was not declared in this scope
- Converting string to ASCII
- got “cannot appear in a constant-expression” when using template
- C++ ostream and ofstream conversions
- C++ discards qualifiers
- What is the source of the data for the ProgramFiles, ProgramW6432Dir, ProgramFilesDir (x86), CommonProgramFiles environment variables?
- C++ : Exception occurred in script: basic_string::_S_construct NULL not valid
- function does not take 1 arguments c++
- overloaded function with no contextual type information
- How exactly do lookup tables work and how to implement them?
- Vector declaration “expected parameter declarator”
- C++ Destructors with Vectors, Pointers,
- error C2065: ‘cout’ : undeclared identifier
- How to get the MD5 hash of a file in C++?
- C++ Error: Expected a type specifier
- Where to declare/define class scope constants in C++?
- Friend methods error
- Does WPF Work with C++?
- Multiple inputs on one line
- Why do I get: -9223372036854775808
- Compiler error C4430: missing type specifier – int assumed [duplicate]
- ‘&’ : illegal operation on bound member function expression [duplicate]
- Multiple definitions of “Main”
- Getting the error floating point exception: 8