Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

the online compiler gives me errors when i inherit from a class to another in c++

0 votes
asked Sep 1, 2021 by Ibraheem Elshahed (120 points)
it gives me the error expected class name before token {

and i have included the parent class and typed the syntax of the inheritance

class child_class_name: access specifier parent_class_name{

1 Answer

0 votes
answered Sep 19, 2021 by Peter Minarik (86,640 points)

Most probably you missed the semicolon (;) after the declaration of one of your classes.

class Shape
{
public:
    unsigned int numVertices;
}; // <<< this is the semicolon that you are most probably missing.

class Triangle : public Shape
{
    
};
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...