Inheritance - no default constructor exists for class "CloudGenerator"

Hello,
It's first time I'm trying inheritance, let me show you guys part of the code :p thanks so much for help! :D

this is Weather.h file:

1
2
3
4
5
6
7
8
9
10
11
12
#include "CloudGenerator.h"
class CloudGenerator;

class Weather : public CloudGenerator
{
public:
	Weather::Weather(engine*theEngine2, LogSystem* logger,GlobalTime* Time2);
	~Weather(void);
private:
CloudGenerator *Cloud;
// functions here 
}


This is Weather.cpp file
1
2
3
4
5
6
7
8
9
#include "includes.h"
#include "CloudGenerator.h"


Weather::Weather(engine*theEngine2, LogSystem* logger, GlobalTime* Time2)
{
Cloud = new CloudGenerator(logger);
//stuff here
}


Im getting following error:
no default constructor exists for class "CloudGenerator",

Does anyone know why I'm getting this? Thanks again for help and your time :)
Last edited on
I have fixed it here's solution if anyone has the same problem :p

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//.h


#include "CloudGenerator.h"

class Weather : public CloudGenerator//class responsible for weather changes, and skybox
{
public:
	Weather::Weather(void);
	Weather::Weather(engine*theEngine2, LogSystem* logger,GlobalTime* Time2);

//.cpp

#include "includes.h"
#include "CloudGenerator.h"

Weather::Weather(void)
{
}

Weather::Weather(engine*theEngine2, LogSystem* logger, GlobalTime* Time2)
{
Weather inherits from CloudGenerator means that a Weather is a CloudGenerator. By default the default constructor (constructor that takes no arguments) of the base class (CloudGenerator in this case) will be used. If you want some other constructor to be used you have to specify in the constructor initializer list:
1
2
3
4
5
Weather::Weather(engine*theEngine2, LogSystem* logger, GlobalTime* Time2)
:	CloudGenerator(logger)
{
	//stuff here
}


Weather has a pointer to a CloudGenerator called Cloud. This has nothing to do with inheritance.
Last edited on
I know that. But since I had no idea where the problem was lying and since Cloud has something to do with CloudGenerator i thought id show that part of the code :p
anyways Thanks for taking your time :)
Last edited on
Topic archived. No new replies allowed.