hey guys im new here and new to programming in C++
i have this project for school and ive hit a dead end.
included i have attached the header, functions cpp, and driver cpp files
when building i get the following error :error C2512: 'automobile' : no appropriate default constructor available
now ive read the other thread in here about that same error but, the difference is that i dont have a class within a class, they are inherited classes.
Re: Inheritance problem (default constructor error)
but i need all of the arguments in each other the classes (planes trains and automobiles) to stay in each of the respective constructors, the values come from the base class vehicles. i still dont really understand the nature of the error.
Re: Inheritance problem (default constructor error)
Mind you.... one very obvious problem is that in function main() you write:-
Code:
automobile myauto;
which means you call a constructor with no parameters. However, you don't have any constructor with no parameters. Your only constructor for automobile takes 4 parameters and you must supply these whenever you instantiate an automobile object.
"A problem well stated is a problem half solved.” - Charles F. Kettering
Re: Inheritance problem (default constructor error)
Oh - and apart from that, you've misunderstood the way that parameters are used in function calles - e.g.
Code:
automobile::automobile(double mpg, double fuelcap, int ftype, int tolls) : vehicle(mpg, fuelcap, ftype)
{
tolls = 25; // This is wrong!!
tollfees = tolls; // This is right
mpg = 20; // This is wrong!!
fuelcap = 15; // and so is this!!
ftype = 0; // and so is this!!
}
The basic idea of parameters is that they pass values into your constructor (or your function). Sometimes they can be used to return values out of a function but that wouldn't work with the type of parameter you've set up. What you did in the constructor for vehicle:-
Re: Inheritance problem (default constructor error)
thank u so much john e i will edit my code and update with the results. i apreciate the help alot man! im so used to vb which was pretty straight forward with functions and passing arguments.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.