An abstract class in C can be inherited
Inheritance with an abstract class
I actually come from Vulkaan Island (Java) and there the story of inheritance is totally clear to me and also as far as the syntax is concerned ...
Unfortunately I am not 100% clear with the syntax in C ++ ...
So this is what I plan to do now:
There is an abstract class boat with the attribute bg (boat weight), a class motorboat with the attribute ml (engine power) and a class sailboat with the attributes sf (sail area) and wg (wind speed) ... The classes motorboat and sailboat should of course inherit from the class boat and realize it ...
I wasn't sure how to create an abstract class in C ++, but there are some examples in Inet, unfortunately most of the examples contain only one method in the class and no attribute ...
My class looks like this:
My other two classes look like this:
<< ICH WERDE DIE KLASSE SEGELBOOT HIER NICHT REINSTELLEN WEIL ES JA EIGENTLICH ÄQUIVALENT IST >>
What I don't like at this point is that I cannot initialize the bg attribute of the Motorboot constructor via the initialization list ...
I have to initialize it in the block ...
Surely it has to work differently, or what is the common way of doing it in C ++?
So if I write a little main now and want to create a motorboat, it looks like this for me:
As soon as I let that run, I get an error in line 9 that tells me:
Variable type "Motorboat" is an abstract class
Why is the motorboat abstract now? : S.
So I'm sure the error is somehow in the syntax or in the way you implement it in C ++ ...
Can someone help me or give me tips?
- Can we use our cell phones in space?
- What are poems about the ideal child
- How do mangoes affect your health?
- A bacterial eye infection is dangerous
- What is the compound name of CaWO3
- What is medical misconduct
- Why did Eminem have to change
- What is the use of electrical tape
- Is Craig Wright Satoshi Nakamoto
- Are doctoral internships lucrative
- How much of Mexico is actually desert
- Regardless of consent, PIV is always rape
- What is a healthy yogurt to eat
- Laser acne scar removal hurts
- What is nanograde
- Can I earn money collecting coins?
- Who assigns cars VIN numbers
- How many bands have you seen live?
- Why do people have language disabilities 1
- Are videos in Unacademy in English
- What is the importance of mycorrhizae
- How big are classic elves
- How can you rent without income
- Why are fire extinguisher pipes not insulated?